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
Post a Comment