2
我有这样的代码:取的NodeJS承诺回调未决
fetch(url).then(response => {
const json = response.json();
console.log('simplest possible fetch', json, json.where);
});
在控制台中我得到:
simplest possible fetch Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined} undefined
我得到这个最的时间。有时我会获得“成功”的地位。对我来说,这意味着回调在获取承诺解决之前正在运行。
我希望函数只在抓取完成时才能运行。我该怎么做呢?
真棒答案亚历克斯! :) @alexmac – turmuka