H
H
hatealleverything2020-10-29 16:18:43
Node.js
hatealleverything, 2020-10-29 16:18:43

Why is the data not being assigned to a variable?

Good afternoon, to be honest, I don’t understand at all why my data is not assigned ... The data is displayed in the console log, but not in the variable, why is that?

let data

connection.query(`SELECT * FROM items`, function (err, results) {
    if (err) console.log(err)
    data = results
})

connection.end();

console.log(data)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ttm, 2020-10-30
@TouchTheMind

if (err) console.log(err)
This console log should contain an error and not data

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question