So, I need a little help regarding a node.js code that I'm trying (more like failing) to write.
It's a simple code, I'm sure, but coming from a C#, .NET background, I still don't understand that much of js, so things can be tricky.
This is my code, currently:
var mysql = require('mysql');
var resultQuery = [];
con.connect(function(err) {
if (err) throw err;
con.query(myQuery, function (err, result, fields) {
if (err) throw err;
resultQuery = result;
});
});
export default function tarefas(request, response){
const taskList = [];
response.json({
taskList: resultQuery
})
}
And as the first response I'll get, it's going to be something like this
Then, if I keep hitting F5, eventually it will bring my list as expected, but I still wasn't able to determine why it doesn't bring the result right away.
Can anybody help me out with this?
Thank you sincerely.