【发布时间】:2021-01-27 21:35:14
【问题描述】:
我不明白为什么我得到 Promise { <pending> },因为我使用了 async/await
这是我的代码
const fetch = require("node-fetch")
function getRandomPokemon() {
var pokemonID = Math.floor(Math.random() * 851);
console.log("The Pokemon Id is " + pokemonID);
return pokemonID
}
async function getJSON() {
let response = await fetch('https://pokeapi.co/api/v2/pokemon/'+ pokemonID);
var json = await response.json
}
var pokemonID = getRandomPokemon()
var json = getJSON()
console.log(json)
【问题讨论】:
标签: javascript node.js async-await es6-promise