I need the results of the array outside of the function. Is there anyway to do that?
I am trying to push the results of a json object to an array to use.
let chan = [];
axios.get(names, {
cancelToken: new CancelToken(function executor(c) {
api_requests.nm = c;
})
})
.then(function(name) {
chan = name.data.map(d => d.elem);
return chan;
}).catch(function(error) {
console.log(error);
alert_error(error);
});
I want to use the results of chan
outside of this function globally. Is there anyway to do that?