I'm trying to create a promise in Angular with the $q service. It returns an object retrieved from a web service. If the object is in the cache, it returns it without calling the web service.
The problem is that the two resolves are getting called.
Maybe, Am I using a promise anti-pattern?
Here is my code:
function returnMapAsync() {
return $q(function (resolve, reject) {
if (navigationMap) {
resolve(navigationMap);
} else {
ServerRequest.getNavigationMap().then(function (data) {
navigationMap = data.object;
resolve(navigationMap);
});
}
});
}
Thank you