我正在尝试将 API 调用响应存储到变量cat
中。当我执行以下代码时,控制台会记录Promise { <pending> }
. 为什么会出现这种情况?
const got = require('got');
let dog = async () => {
try {
const response = await got('https://api.coinpaprika.com/v1/coins/btc-bitcoin');
return response;
} catch (error) {
console.log(error.response.body);
//=> 'Internal server error ...'
}
}
let cat = dog();
console.log(cat)