第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Discord Roblox 機器人

Discord Roblox 機器人

阿晨1998 2024-01-18 14:54:04
我正在嘗試創(chuàng)建一個命令來輸出玩家收藏品并總結recentAveragePrice列出的物品總數(shù)。問題是當我嘗試輸出此 API 的任何部分時,它只是輸出undefined.API URL: https://inventory.roblox.com/v1/users/1417341214/assets/collectibles ?assetType=Hat&sortOrder=Desc&limit=100if (command === "inv"){    let getInv = async () => {        let response = await axios.get("https://inventory.roblox.com/v1/users/1417341214/assets/collectibles?sortOrder=Asc&limit=100");        let inv = response.data;        return inv;    }    let invValue = await getInv();    console.log(invValue);    message.channel.send(`${invValue.data.name} \n ${invValue.data.recentAveragePrice}`);}
查看完整描述

1 回答

?
有只小跳蛙

TA貢獻1824條經(jīng)驗 獲得超8個贊

這是因為返回的數(shù)據(jù)是一個對象數(shù)組。如果您想將它們?nèi)孔鳛橄l(fā)送,您可以迭代它們。如果您想將它們一一發(fā)送,可以使用以下方法:


if (command === 'inv') {

  const getInv = async () => {

    const response = await axios.get(

      'https://inventory.roblox.com/v1/users/1417341214/assets/collectibles?sortOrder=Asc&limit=100',

    );

    return response.data;

  };

  const invValue = await getInv();

  let total = 0;

  invValue.data.forEach((item) => {

    message.channel.send(`${item.name} \n ${item.recentAveragePrice}`);

    total += item.recentAveragePrice;

  });

  message.channel.send(`Total average price: ${total}`);

}

結果:

https://img1.sycdn.imooc.com/65a8cb2b0001542004480435.jpg

查看完整回答
反對 回復 2024-01-18
  • 1 回答
  • 0 關注
  • 128 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號