I would like to return the value of a second promise if the first (value in cache) fails.
I have the following code, but 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) {
//return value of the promise that was called
resolve(result)
})
}
};
Assume that both getConfigFromCache and getRouteConfigFromWeb return promises correctly.
Is there a way to accomplish this, or am I thinking through it incorrectly?