Post
Topic
Board Service Discussion
Re: accessing coinbase API using node.js
by
Joel_Jantsen
on 07/05/2017, 18:40:11 UTC
Try the following code and let me know if that works.I don't really want to run the app locally so it will be better if you add on skype or something,much better to solve in real time.
Code:
client.getAccounts({}, function(err, accounts) {
  accounts.forEach(function(acct) {
    console.log(acct.name + ': ' + acct.balance.amount + ' ' + acct.balance.currency);
    acct.getTransactions(null, function(err, txns) {
      txns.forEach(function(txn) {
        console.log('txn: ' + txn.id);
      });
    });
  });
});

Yes that API keys should be passed a string only.

The error occurs at this line
Code:
accounts.forEach(function(acct) {
the extra code added comes after the error occurs and the app has already crashed.
Pretty sure you're doing something wrong.Have tested the network part in the console ? Is it receiving any data back ? Want me to take a look through teamviewer ? Otherwise I'll implement it locally tomorrow and check where you're going wrong..