Angular 2. How to handle 4xx errors with redirect in Observable?

前端 未结 1 1439
隐瞒了意图╮
隐瞒了意图╮ 2021-01-02 10:01

I have a service that calls an api

getItems(itemId: number): Observable {
    return this.http.get(url, headers)
        .map(this.extractDataSing         


        
相关标签:
1条回答
  • 2021-01-02 10:30

    I guess this does what you want:

    private handleError = (error: any) => {
       this._router.navigate(['Login']);
       return Observable.of([]);
    }
    
    0 讨论(0)
提交回复
热议问题