Async Function returns Promise pending

I don’t understand why i get Promise { <pending> } since i used async/await

this is my code

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)

82 thoughts on “Async Function returns Promise pending”

Leave a Comment