我已经成功从这个异步/等待函数中检索到一个Promise:
const fetchJSON= (async () => {
const response = await fetch('http://localhost:8081/getJavaMaps')
return await response.json()
})();
现在我想将结果转换或分配给一个数组。这是在console.log(fetchJSON)中结果的样子:
[[PromiseResult]]: Object
One: "Batman"
Three: "Superman"
Two: "Ironman"
但是当我执行以下操作:
console.log(fetchJSON.One);
console.log(fetchJSON.length);
我总是得到:
undefined
我尝试过这个:
let myarray = Object.entries(fetchJSON);
但它没有将PromiseResult对象转换为二维数组。