我的请求大约需要2-5分钟,但总是会在30秒后中断
有什么方法可以增加请求超时或防止使用angular 8.x自动取消请求?
答案 0 :(得分:1)
您需要使用超时运算符。从rxjs 5.5.2开始,您需要将管道方法与可操作的运算符一起使用。并且假设您使用HttpClient发出请求,则不需要映射(response => response.json())。
赞:
从'rxjs / operators'导入{超时,catchError}; 从“ rxjs / observable / of”导入{of};
http.get('https://example.com') 。管( 超时(2000) catchError(e => { //做超时 返回(null); }) )