Skip to content
This repository was archived by the owner on Dec 26, 2024. It is now read-only.

fix error handling edge case #9

Merged
merged 1 commit into from
Sep 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ module.exports = function (apiKey, chain) {
return reject(data.message);
}

if (data.error) {
return reject(data.error.message);
}

resolve(data);
});
});
Expand Down Expand Up @@ -198,11 +202,11 @@ module.exports = function (apiKey, chain) {
* var res = api.proxy.eth_getTransactionByHash('0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1');
* @returns {Promise.<object>}
*/
eth_getTransactionByHash(hash) {
eth_getTransactionByHash(txhash) {
const module = 'proxy';
const action = 'eth_getTransactionByHash';
var query = querystring.stringify({
module, action, apiKey, hash
module, action, apiKey, txhash
});
return getRequest(query);
},
Expand Down Expand Up @@ -494,7 +498,7 @@ module.exports = function (apiKey, chain) {
* var supply = api.account.tokenbalance(
* '0x4366ddc115d8cf213c564da36e64c8ebaa30cdbd',
* 'DGD',
* ''
* ''
* );
* @returns {Promise.<object>}
*/
Expand All @@ -519,7 +523,7 @@ module.exports = function (apiKey, chain) {
if (address) {
queryObject.address = address;
}

var query = querystring.stringify(queryObject);
return getRequest(query);
},
Expand Down