Cha*_*har 5 finally httpclient angular-http angular angular-httpclient
在以前的 Angular 版本中,我使用的finally()就像下面的代码一样
constructor(
private http: Http
) { }
const headers = new Headers({ 'Authorization': this.authenticate.getToken(), 'Content-Type': 'application/json' });
const options = new RequestOptions({ headers: headers });
return this.http.put(Globals.SERVER_URL + '/alert/exempted?_id=' + alertId + '&isExempted=' + status + '&app_id=' + app_id, options )
.map(this.extractData)
.catch(this.handleError)
.finally(() => {
this.exceptionSubject.next();
});
Run Code Online (Sandbox Code Playgroud)
但是现在使用 Angular 7 时,我不能再使用它了。如何在代码中插入finally(HttpClient)?这是我现有的代码:
constructor(
private http: HttpClient
) { }
const header = new HttpHeaders({'Content-Type': 'application/json'});
return this.http.get(Globals.ATTENDANCE_URL + '/individual_employment_setting/detail/' + id, { headers: header })
.pipe(tap(resp => {
if (resp['success'] === true) {
localStorage.setItem('settings', JSON.stringify(resp['data']));
}
}
));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1232 次 |
| 最近记录: |