Not the brightest with async JS yet but after trying many different variations after many google searches and getting nowhere thought I'd finally ask for some help. (My way of saying please be easy on me for what is probably a dumb question)
What I'm trying to do is get the data object and store it to be used elsewhere in the code. Below is the latest thing I tried and am getting a result of undefined from the console.log().
let apiData;
const getData = async () => {
const response = await fetch('myapirurl');
const data = await response.json();
return data;
}
getData().then(result => {
apiData = result;
})
console.log(apiData);