Return promise inside resolve function as its continuation
|Added at||2016-12-28 18:12|
I'm working with Angular. I have a service called UserService, that handles login, authentication and user data requests.
The get method needs to check if the user has a valid (not expired) token for authentication before making the
This get method needs to hide its complex requests. It has to return only a Promise as it was making only one request.
So, an example of usage:
Check if the token is expired. If it is, return a request to refresh the token, and there, make and return the get request. If it is not, just make and return the get request. As below:
But it's returning a promise that I will have to handle like this:
Anything like the usage example!
How to make this get method on service, which handles authentication like that and hides everything from the controller that will use, letting it like in the usage example?