0

I'm trying to fetch an API and it's working but for the problem that my variable GOT will not console.log. If I write it into the web dev tools I can see the object in the console but I can't console log it from my editor. This is probably not a great question. I'm relatively new to the game. thanks!

let url = "https://www.anapioficeandfire.com/api/characters";

let GOT;

fetch(url)
  .then((response) => {
    return response.json();
  })
  .then((response) => {
    GOT = response;
    console.log(GOT);
    return GOT;
  });

console.log(GOT);
ibrahim mahrir
  • 31,174
  • 5
  • 48
  • 73

0 Answers0