Why can't I call resolve in the catch block ?
Wanted catch a failed request and try it again in the catch block but I'm getting resolve is not defined. I'm inside of the promise why cant I call resolve
module.exports.makeRequest = function(ID,requestAttempts) {
return Promise()
.then(function(val, resolve, reject){
request.get(url, {json:true}, function(err, res) {
if(err || res.body.error_code)
reject(err || res.body)
else
resolve(res.body)
})
})
.catch(function (error) {
if (requestAttempts <= 0) reject(error);
console.log("Error :",error, `\n Try to repead the request (attempts left: ${requestAttempts} )`);
resolve(makeRequest(ID,requestAttempts - 1)); //HERE
});
}