I have a JSON file that I store in my project and when i Fetch this file I want to store the result in a global variable so I can use it later whenever I want! So my question is: is it there a way to put this data into a global variable something like this:
let globalData;
fetch('./../JSON.json')
.then((response) => response.json())
.then(JsonData => {
globalData = JsonData;
}).catch(error => console.error)
console.log( globalData ) // return undifined
Thank you!