我知道有很多类似的主题,但我仍然对解决这个问题感到困惑,我想从 API 中读取余额和费率,但是我收到挂起/超时错误或 UnhandledPromiseRejectionWarning 消息,通常如何处理此错误在 Node.js 中,谢谢
binance.balance((error, balances) => {
if ( error ) return console.error(error);
var keyN = Object.keys(balances);
let coincount = keyN.length; //406
var StBalance = JSON.stringify(balances);
var PsBalance = JSON.parse(StBalance);
async function bAll() {
for (var i = 0; i < coincount ; i++) {
var coinName = keyN[i];
var coinBalance = Object.values(PsBalance[coinName])[0];
var myPair = keyN[i]+'USDT';
let ticker = await binance.prices(myPair) ;
let cRate = Number(Object.values(ticker));
console.info('Rate of ',myPair,': ',cRate);
console.info('balance of ',coinName,': ', coinBalance);
console.info('Value of ',coinName,' amount to USDT',cRate*coinBalance);
}
}
bAll();
});