chore(api): add logs for success call

This commit is contained in:
George Lima 2019-05-30 00:37:37 -03:00
parent d4a53ce0bd
commit 4cc4645ff3
1 changed files with 9 additions and 6 deletions

View File

@ -8,18 +8,18 @@ import store from '../config/electron-store';
import { isTestnet } from '../config/is-testnet'; import { isTestnet } from '../config/is-testnet';
const getRPCConfig = () => { const getRPCConfig = () => {
const rpcport = store.get('rpcport'); const rpcport: string = store.get('rpcport');
const rpcconnect = store.get('rpcconnect'); const rpcconnect: string = store.get('rpcconnect');
return { return {
host: rpcconnect || '127.0.0.1', host: rpcconnect || '127.0.0.1',
port: rpcport || (isTestnet() ? 18232 : 8232), port: rpcport || (isTestnet() ? 18232 : 8232),
user: store.get('rpcuser'), user: (store.get('rpcuser'): string),
password: store.get('rpcpassword'), password: (store.get('rpcpassword'): string),
}; };
}; };
const getMessage = (statusCode, isECONNREFUSED) => { const getMessage = (statusCode: number, isECONNREFUSED: boolean) => {
if (isECONNREFUSED) { if (isECONNREFUSED) {
return 'Zepio could not find a daemon running, please check the logs!'; return 'Zepio could not find a daemon running, please check the logs!';
} }
@ -53,7 +53,10 @@ const api: APIMethods = METHODS.reduce(
params: args, params: args,
}, },
}) })
.then(data => Promise.resolve(data.body && data.body.result)) .then((data) => {
console.log('[RPC CALL SUCCESS] -', method, data.body.result);
return Promise.resolve(data.body && data.body.result);
})
.catch((payload) => { .catch((payload) => {
console.log( console.log(
'[RPC CALL ERROR] - ', '[RPC CALL ERROR] - ',