I'm learning to use the mysql
module of the node and I came across a situation where I can not assign the result to a global variable, follow my code:
let data = 0
connection.query(query, (err, rows, fields) => {
if (err) {
console.log('An error ocurred performing the query.')
console.log(err)
return
}
data = rows
})
If I print the variable data
the result is zero, how do I assign the result to it?
obs: I used this example documentation.