I try to import a json file (data.json) in javascript file. This is my code:
function grabData() {
    fetch("./data.json")
    .then(response => {
        return response.json().then(function(data) {
            var dataExport = data;
            console.log(dataExport)
        });
    })
}
grabData()
console.log(dataExport)However, the variable (dataExport) works only on a function.
How i can access at this variable outside of my function?
 
     
    