What I tried - I created an empty variable that has an initial value of an empty array, inside fetch I have pushed the response to an empty array but not able to get data.
let covidData=[];
function fetchData(){
fetch('https://jsonplaceholder.typicode.com/users')
.then(response=>response.json())
.then(data=>
covidData.push(data)
)
.catch(error=>{
console.log("error",error)
})
}
fetchData();
console.log(covidData)
Currently, I'm am getting an empty array