Thursday, 27 April 2017

Warning: a promise was created in a handler - bluebird

I'm getting below warning error, please guide me to fix it.

Warning: a promise was created in a handler at anonymous> (/opt/testproj/node_modules/pipeworks/pipeworks.js:72:17but was not returned from it, see http://bluebirdjs.com/docs/warning-explanations.html#warning-a-promise-was-created-in-a-handler-but-was-not-returned-from-it at new Promise (/opt/testproj/node_modules/bluebird/js/release/promise.js:77:14)

Sample code:

const bluebird = require('bluebird');
const options = {
                  promiseLib: bluebird
                };
const pgpromise = require('pg-promise')(options);
const connectionString = `postgres://${user}:${password}@${host}:${port}/${database}`; 
const db = pgpromise(connectionString);


db.func('student__find_by_id', [id])                                       
.then((data) => {                                                                                                                   
  return res.json(data);
}).catch((err) => {
   log.error(err);                                                                                                              
});



via thavaamm

No comments:

Post a Comment