D
Size: a a a
D
J
return next.handle(req).catch(err => {
if (err.status === 401) {
if (err.error.message == “some condition token exp) {
//Genrate params for token refreshing
let params = {
token: token,
refreshToken: localStorange("refreshToken");
};
return this.http.post('localhost/auth/refresh', params).mergeMap(
(res: any) => {
//If reload successful update tokens
if (res == 200) {
//Update tokens
localStorange.setItem("api-token", res.result.token);
localStorange.setItem("refreshToken", res.result.refreshToken);
//Clone our fieled request ant try to resend it
req = req.clone({
setHeaders: {
'api-token': res.result.token
}
});
return next.handle(req).catch(err => {
//Catch another error
});
}else {
//Logout from account
}
}
);
}else {
//Logout from account or do some other stuff
}
}
return throwError(err);
});
J
D
OS
IH
IH
К
<header-template></header-template>
<div class="title">List of songs</div>
<div class="list-group">
<a
href="#"
class="list-group-item list-group-item-action"
ng-repeat="item in ctrl.globalState.songsData"
>
{{item.title}}
</a>
</div>
S
<header-template></header-template>
<div class="title">List of songs</div>
<div class="list-group">
<a
href="#"
class="list-group-item list-group-item-action"
ng-repeat="item in ctrl.globalState.songsData"
>
{{item.title}}
</a>
</div>
G
E
G
G
IF
G
n
VY
VY
J