How do you call a function from within fetch.then after the data is fetched? I've also tried just returning the data, but that also fires before the data comes back.
Below, the console.log(data) line waits for the data, but getElements is called immediately, resulting in a console.log of "undefined yo".
fetch('https://opentdb.com/api.php?amount=5&category=9&difficulty=easy&type=multiple')
.then(res => res.json())
.then(data => {
console.log(data)
getElements(data)
})
.catch(error => { console.log(error); })
}
function getElements(something) {
console.log(something, "yo")
}
getQuestions()```