有没有人对 node.js 使用 coinbase API 的经验
我正在关注npm coinbase文档,但它不起作用。我只是想获得比特币的价格。我确实首先在两者之间安装了coinbase,所以这不是问题。
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);
});
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行它时,它给了我以下错误:
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 ('总金额:' + obj.data.amount);
类型错误:无法读取 null 的属性“数据”
当我运行它时,它总是返回 NULL。