0
當我運行這個文件時,我什麼也沒得到。如果我運行,而不是console.log(getInfo());
最後我剛剛得到Promise <pending>
。請幫忙。我的api請求沒有返回任何內容,也沒有任何錯誤消息
function getInfo(){
var url = `https://api.nutritionix.com/v1_1/search/cheddar%20cheese?fields=item_name%2Citem_id%2Cbrand_name%2Cnf_calories%2Cnf_total_fat&appId=${apiId}&appKey=${apiKey}`;
return(
fetch(url)
.then(data=>{
return JSON.parse(data);
})
);
}
getInfo().then(result =>{
console.log(result);
@JF如何被鏈接的問題與當前的問題? – guest271314
@ZachFrotten請參閱https://stackoverflow.com/help/someone-answers – guest271314