node.js - return value from promise Sequelize -


i'm working sequelize, i'm having trouble requisition's return.

this got far:

var m = messagem.findall({}).then((mensagens)=>{ console.log(mensagens); //  have reponse :d return mensagens; });  console.log(m);  promise { _bitfield: 2097152, _fulfillmenthandler0: undefined, _rejectionhandler0: undefined, _promise0: undefined, _receiver0: undefined, _boundto: messagem } 

what doing wrong?

any appreciated!

you cannot return value promise resolution handler (well, can, result of resolution or rejection of promise returned .then() method itself, in example).

in case m promise need use such. instead of:

console.log(m); 

you have do:

m.then(console.log); 

or this:

console.log(await m); 

if inside function declared async keyword.

see this answer more info that. see other answers promises.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

python - Error: Unresolved reference 'selenium' What is the reason? -

asp.net ajax - Jquery scroll to element just goes to top of page -