Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Error getting deposits list #44

Closed
ysilvela opened this issue Dec 14, 2015 · 2 comments
Closed

Error getting deposits list #44

ysilvela opened this issue Dec 14, 2015 · 2 comments

Comments

@ysilvela
Copy link

I obtain this error when I call to getDeposits method:

TypeError: Cannot read property 'resource' of undefined
at onGet (/var/lib/openshift/5562dcd5500446389000024c/app-root/runtime/repo/node_modules/coinbase/lib/model/AccountBase.js:61:62)
at Request.onGet as _callback
at Request.self.callback (/var/lib/openshift/5562dcd5500446389000024c/app-root/runtime/repo/node_modules/coinbase/node_modules/request/request.js:344:22)
at Request.emit (events.js:98:17)
at Request. (/var/lib/openshift/5562dcd5500446389000024c/app-root/runtime/repo/node_modules/coinbase/node_modules/request/request.js:1239:14)
at Request.emit (events.js:117:20)
at IncomingMessage. (/var/lib/openshift/5562dcd5500446389000024c/app-root/runtime/repo/node_modules/coinbase/node_modules/request/request.js:1187:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:442:13)

And the code is:

    var client   = new coinbase.Client({'apiKey': clientAcc.KEY1, 'apiSecret': clientAcc.KEY2});
    client.getAccounts({}, function(err, accounts) {
      accounts.forEach(function(acct) {
        console.log('matchAccountTxWithRequests. Balance: ' + acct.balance.amount + ' para ' + acct.name);
              var args = {
                'colName'  : 'deposits',
                'ObjFunc'  : Deposit,
              };
            acct.getDeposits(args,function(err, txs) {
              txs.forEach(function(txn) {
                console.log('matchAccountTxWithRequests. txn details (' +  clientAcc.ClientId + ',' +  acct.name + ') : ' + JSON.stringify(txn));
              });
            });
      });
    });

Any Idea?

@manuel-di-iorio
Copy link
Contributor

I confirm the issue.

And before the @ysilvela's error log, there is even:
var ObjFunc = self.client._stringToClass(result.data[0].resource);

Pratically, the same bug as #37


The first problem is that lib/model/AccountBase.js:61 does not handle an empty data array.
The second problem (and the origin) is that, the result array is always empty, even if there are deposits.

I see that in the same file, other onGet methods use: obj.data.resource instead of result.data[0].resource. Could this be related?

@maksim-s
Copy link
Contributor

Fixed here 288d1b7

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants