Using code
let data;
fetch(url)
    .then(result => result.json())
    .then(json => {data = json})
console.log(data)
data console logs as undefined, whereas
let data;
    
fetch(url)
    .then(result => result.json())
    .then(json => console.log(json))
logs the result as expected. How come? How can I store result of fetch in a variable for future use?
