⬅︎ Back to To then() or to success() in AngularJS
What I ended up doing is simulating the '.success' and '.error' promises of $http, and using an $http-like API everywhere for my service.I'm not sure if this is bad, but I did this when returning a cached object: return {success: function(f){ f(cachedObject.response); }, error: function(f){ }}When the item is NOT cached, I simply return the original $http promise. So I can use my service like an $http promise everywhere...which is what I want to do because it is convenient.
Comment
What I ended up doing is simulating the '.success' and '.error' promises of $http, and using an $http-like API everywhere for my service.
I'm not sure if this is bad, but I did this when returning a cached object:
return {success: function(f){
f(cachedObject.response);
},
error: function(f){
}}
When the item is NOT cached, I simply return the original $http promise. So I can use my service like an $http promise everywhere...which is what I want to do because it is convenient.