I am trying to handle the scenario where I need to return the value of a second promise if the first one (value in cache) fails.
Below is my code snippet, but I'm encountering an issue where 'resolve' is not defined.
exports.getConfig = function (a, r) {
return new Promise(resolve, reject) {
getConfigFromCache(a, r)
.catch(function(e){
getRouteConfigFromWeb(a, r)
}).then(function(result) {
//returning the value of the called promise
resolve(result)
})
}
};
Assuming that both getConfigFromCache and getRouteConfigFromWeb functions correctly return promises, is there a way to achieve this or am I approaching it incorrectly?