How can i return an Observable in the private method if i have to return
the Cookie if i don't need to refresh?
Isn't the same thing that i'm doing here?
if (!Cookie.get("access_token")) {
this.getRefresh(Cookie.get("refresh_token"))
.subscribe(
data => this.saveToken(data),
err => alert('Invalid Credentials')
);
cookie = Cookie.get("access_token");
Il giorno mercoledì 12 luglio 2017 07:51:30 UTC+2, Zlatko Đurić ha scritto:
>
> Well it's not"after the map" that's the problem here, it's"after the map
> has resolved".
>
> So in your use case when you need to call getRefresh, you would have to
> chain the two calls; first, call the refresh token endpoint, and when it
> comes back, than you can use your cookie.
> So your "resource" call would make two chained calls and return the result
> of the second call. You can do that by returning a flatMap instead of map.
> But that would do just for the branch with no cookie set in advance.
> Now to streamline it, maybe _always_return a flatMap and get the cookie in
> s separate private method that returns the cookie if there, or fetches it
> if not. And the return is always an observable you can subscribe to.
>
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.