Friday, 28 April 2017

unhandled promise rejection node.js

I think I'm missing something small. I keep getting UnhandledPromiseRejectionWarning. I've been combing mdn as well as SO for answers, I need another set of eyeballs on my code.

Thanks

calling promise

proxySvc.setIfElite(proxy)
  .then(success => {
    console.log(success.msg)
  })
  .catch(err => {
    console.error(err.msg)
});

Promise Method

proxySvc.setIfElite = function (P) {
//
return new Promise((resolve, reject) => {
    ProxyVerifier.testAnonymityLevel(P, (error, anonymityLevel) => {
  setCounter();
  if (error || anonymityLevel !== 'elite') {
    reject({
      status: false,
      msg: 'test failure'
    })
  };

 resolve({
      status: true,
      msg: P.ipAddress
    });
 });

})



via Nigel Alford

No comments:

Post a Comment