I am having an error: (node:6186) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): threep (node:6186) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. -------- ones ========= two CaughtCathchError threep (node:6186) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1) I am consuming my 3 promise functions in nested order. p1,p2,p3- are my promise functions as shown below. i tried adding promise reject in all p1,p2,p3 functions as well but its still the same
enter code here
var p1 = new Promise(function (resolve, reject) {
setTimeout(function () {
// resolve('ones')
resolve('ones')
}, 9000)
})
var p2 = new Promise(function (resolve, reject) {
setTimeout(function () {
// throw new Error('eeeee');
//reject('two')
resolve('two')
}, 1000)
})
var p3 = new Promise(function (resolve, reject) {
setTimeout(function () {
reject('three')
}, 4000)
})
p1.then(function(result){
console.log("--------", result)
// return p2.then(function(res){console.log(res)}).catch(function(err){console.log(err)})
return p2
}).then(function(p2result){
console.log("=========", p2result)
return p3;
}).then(function(p3result){
console.log('*********', p3result)
}).catch(function(err){
console.log("CaughtCathchError", err)
})
p3 = new Promise
etc ? you're not handling that rejection - Jaromanda X.catch()
. - jfriend00