【发布时间】:2020-12-20 21:53:17
【问题描述】:
{"success":true,"lastUpdated":1598982272495,"products":{"BROWN_MUSHROOM":{"product_id":"BROWN_MUSHROOM","sell_summary":[{"amount":160,"pricePerUnit":13.9,"orders":1},{"amount":28503,"pricePerUnit":13.8,"orders":2},{"amount":71483,"pricePerUnit":13.4,"orders":3},
这就是 api 所说的,所以我假设我可以直接得到“pricePerUnit。但我得到了错误TypeError: Cannot read property 'pricePerUnit' of undefined
我的代码是:```client.on("message", message => { 如果(message.author.bot)返回;
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if (command === "bazaar") {
let product = args[0];
fetch(`https://api.hypixel.net/skyblock/bazaar/product?key=${key}`)
.then(result => result.json())
.then(({ BROWN_MUSHROOM }) => {
// Log the player's username
message.reply(BROWN_MUSHROOM.pricePerUnit)
})
}
})```
有人知道怎么帮忙吗?
【问题讨论】:
标签: javascript api discord.js