节点 Discord Bot Api 股票报价
Node Discord Bot Api Stock Quote
您好,我想知道以下代码中是否有任何语法错误会阻止交易品种、名称和价格通过:
if (command === 'getQuote') {
let getQuote = async () => {
let response = await axios.get(
'https://financialmodelingprep.com/api/v3/quote/AAPL?apikey=demo'
);
let quote = response.data
return quote
};
let quoteValue = await getQuote();
console.log(quoteValue);
message.reply(
`Heres your quote\n${quoteValue.symbol}\n\n${quoteValue.name}\n\n${quoteValue.price}`
);
}
您似乎从 API 获取了一个数组,但您却将 quoteValue
视为一个对象。
检查此代码和框:
https://codesandbox.io/s/infallible-dan-4nc4m?file=/src/index.js
您好,我想知道以下代码中是否有任何语法错误会阻止交易品种、名称和价格通过:
if (command === 'getQuote') {
let getQuote = async () => {
let response = await axios.get(
'https://financialmodelingprep.com/api/v3/quote/AAPL?apikey=demo'
);
let quote = response.data
return quote
};
let quoteValue = await getQuote();
console.log(quoteValue);
message.reply(
`Heres your quote\n${quoteValue.symbol}\n\n${quoteValue.name}\n\n${quoteValue.price}`
);
}
您似乎从 API 获取了一个数组,但您却将 quoteValue
视为一个对象。
检查此代码和框:
https://codesandbox.io/s/infallible-dan-4nc4m?file=/src/index.js