我有一个请求大约需要2-5分钟,但它总是在30秒内中断
有没有办法增加请求超时或防止请求在angular 8.x中被自动取消?
发布于 2020-04-28 01:28:25
您需要使用超时运算符。从rxjs 5.5.2开始,您需要将管道方法与lettable操作符一起使用。
如下所示:
从‘rxjs/operators’导入{ timeout,catchError };从‘rxjs/observable/ of’导入{of};
http.get('https://example.com') .pipe( timeout(2000),catchError(e => { //在超时返回(Null)时做某事;}) )
https://stackoverflow.com/questions/61464530
复制相似问题