Is there anyone experience with using coinbase API for node.js
I am following the npm coinbase documentation but It is not working. I am simply trying to get the price of the bitcoin. I did first installed coinbase between, so that is not the problem.
const config = require('../configuration')
const coinbase = require('coinbase')
const apiKey = config.get('COINBASE_API_KEY')
const apiSecret = config.get('COINBASE_API_SECRET')
const client = new coinbase.Client({apiKey, apiSecret})
module.exports = {
start: async () => {
client.getBuyPrice({'currencyPair': 'BTC-USD'}, function(err, obj) {
console.log('total amount: ' + obj.data.amount);
});
}
}
When I run it, it gives me the following error:
C:\Users\msaad\VisualStudioProjects\CryptoTrader-master\session-1>node index.js C:\Users\msaad\VisualStudioProjects\CryptoTrader-master\session-1\src\app\index.js:12 console.log('total amount: ' + obj.data.amount);
TypeError: Cannot read property 'data' of null
It always returns NULL when I run it.