My problem is very simple, I need to put my data taken from the database in a variable but I don't know how to keep the variable defined. At the end of the pool the data went out and left the variable not defined.
So I have tried to make a res.send to send the data to the next :
.post('/route', data ,function(req, res){
...
});
but I think this is not a good idea.
.post('/musicbrainz/research/', function(req, result, next){
var nomArtiste = req.body.recherche;
var query = "SELECT idartiste * FROM artiste);";
db.query(query, (err, res) => {
if (err) {
return next(err);
}
rows = res.rows;
});
})
.get('/musicbrainz/results/', rows, function(req, res){
const results = rows;
...
My variable rows are undefined when it exits the db.query function.