I am facing this weird issue where the content of my array variable is available in nested functions, but not on the same level where it was declared?
const add_opted_out = (req, res) => {
var opted_out = new Array()
axios.get(url).then((res) => {
parseString(res.data, (err, result) => {
opted_out.push('a')
// prints members
console.log(opted_out)
})
}).catch((err) => {
console.log(`error occured: ${err}`)
})
// prints nothing
console.log(opted_out)
Why is this behaviour?