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

getProductTrades returns undefined #244

Closed
radiantone opened this issue Jan 21, 2018 · 2 comments
Closed

getProductTrades returns undefined #244

radiantone opened this issue Jan 21, 2018 · 2 comments

Comments

@radiantone
Copy link

Hi,
Looks as though this is not returning results.

const Gdax = require('gdax');
const publicClient = new Gdax.PublicClient();
publicClient.getProductTrades('BTC-USD', function(trades) {
console.log(trades);
});

@rmm5t
Copy link
Contributor

rmm5t commented Jan 21, 2018

You're using the callback signature. Like every callback in node, the first argument is always the error. The current GDAX callback signature passes 3 arguments to the callback function (err, response, and data). You're incorrectly assuming that only data is passed, and because there's no error, you're merely logging the null error argument.

Your code should instead read:

publicClient.getProductTrades('BTC-USD', function(err, response, trades) {
  console.log(trades);
});

// OR, more idiomatically:
publicClient.getProductTrades('BTC-USD', (err, response, trades) => console.log(trades))

Alternatively, use the Promise signature:

publicClient.getProductTrades('BTC-USD').then(console.log);

For more information read:


Please close this issue.

@radiantone
Copy link
Author

I appreciate that clarification. Thank you.

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

2 participants