![](/img/trans.png)
[英]Is there a way to get the HTTP status code in angular with retry using of rxjs operators?
[英]How to retry a http request untill a data is recieved using RXJS in Angular
有一个API发送了HTTP请求,很长时间没有响应,但是当用户刷新页面时,API立即响应这种行为经常发生,所以我想使用RXJS来解决这个问题。 当 API 在 40 秒内没有响应时,它应该自动重试 HTTP 请求并且应该尝试 3 次。 如何使用 RXJS 实现这种行为
这是代码:
ABC服务.ts
getABC() {
return this.http
.get(.........)
.pipe(
map(responseData => {
return responseData
}),
catchError(errorRes => {
return this.handleError(errorRes);
})
);
}
XYZ.component.ts
this._abcService.getABC().subscribe((res: any[]) => {
console.log(res);
}, error => {
console.log(error);
});
帮我解决这个问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.