gpt4 book ai didi

javascript - 在javascript中显示从api调用的特定数据

转载 作者:行者123 更新时间:2023-12-02 21:05:36 25 4
gpt4 key购买 nike

这将是一个非常简单的问题,但坦率地说,我无法用自己的语言来找到答案。我应该能够给出答案。

client.getWalletBalance({coin: 'ETH'})
.then(result => {
console.log(result.ETH.available_balance);
var availableBal = result;
})
.catch(err => {
console.error(err);
});

later in the code:

'wallet balance:' + availableBal + ' ETH'

类型错误:无法读取未定义的属性“available_balance”

ReferenceError:availableBal 未定义

<小时/>

这是响应示例

{
"ret_code": 0,
"ret_msg": "OK",
"ext_code": "",
"ext_info": "",
"result": {
"ETH": {
"equity": 1002, //equity = wallet_balance + unrealised_pnl
"available_balance": 999.99987471, //available_balance
"used_margin": 0.00012529, //used_margin = wallet_balance - available_balance
"order_margin": 0.00012529, //Used margin by order
"position_margin": 0, //position margin
"occ_closing_fee": 0, //position closing fee
"occ_funding_fee": 0, //funding fee
"wallet_balance": 1000, //wallet balance. When in Cross Margin mod, the number minus your unclosed loss is your real wallet balance.
"realised_pnl": 0, //daily realized profit and loss
"unrealised_pnl": 2, //unrealised profit and loss
"cum_realised_pnl": 0, //total relised profit and loss
"given_cash": 0, //given_cash
"service_cash": 0 //service_cash
}
},
"time_now": "1578284274.816029",
"rate_limit_status": 98,
"rate_limit_reset_ms": 1580885703683,
"rate_limit": 100
}

本质上我试图选择响应的特定部分,将其设置为变量并稍后重用

最佳答案

那里缺少 .result
result.result.ETH.available_balance

您可能会感到困惑,因为您的变量也被命名为result

关于javascript - 在javascript中显示从api调用的特定数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61233622/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com