Angular - Catching error after all HTTP retry failed

后端 未结 4 2055
走了就别回头了
走了就别回头了 2021-01-07 10:06

I am using Angular Service to get data from my API. I implemented retry feature in case of fetching data fails. Now i need to handle the error when all the retr

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-07 11:13

    Have you tried retry(10)? Then in the second subscribe callback you can handle the error:

    return this.http.get(callURL,{
      params: new HttpParams()
        .set('page', page)
        .set('limit', limit)
    }).pipe(
      retry(10)
    ).subscribe((res) => {}, (e) => {
      // handle error
    });
    

提交回复
热议问题