I am getting data from an API. I need this response data to use outside of axios, not inside any function but globally available in JavaScript, HTML DOM.
let responseData = [];
axios
.get(url)
.then(res => {
responseData.push(res.data.data);
});
console.log(responseData);
console.log(responseData);
gives the output:
[]
inside this array is another array of objects [{},{},{}]
[[{},{},{}]]
But the format I need is [{},{},{}]
Any idea how should I approach this?