If I understand right I should be able to get the promise the way like that:
var helper = null;
MyModel.findAll().then(result => { helper = result });
In the examples this should be enough, but I do not get anything. If I assign a variable for the whole call I get promise pending. The only "difference" I see from the examples is that I call it in an http request:
exports.somePostRequest = (req, res, next) => {
var helper = null;
myModel.findAll().then(result => { helper = result });
}
This works perfectly:
exports.anOtherrequest = (req, res, next) => {
myModel.findAll()
.then(result => {
res.status(200).json({message: result})})
}
Some of the examples I was looking at: https://sequelize.org/v3/docs/models-usage/ How to update a record using sequelize for node?
Any suggestion why this does not work?