使用这段代码,我可以捕获所有异常,除了服务器可用时的异常。您知道应该如何处理吗?
return this.http.post<User>(this._appSetting.ebit.base_url "rested/login/login", JSON.stringify(params), httpOptions)
.pipe(catchError(this.handleError));
Run Code Online (Sandbox Code Playgroud)
您可以使用timeout()运算符来捕获超时。它以毫秒为单位,因此10000为 10 秒。
return this.http.post<User>(this._appSetting.ebit.base_url "rested/login/login", JSON.stringify(params), httpOptions)
.pipe(timeout(10000), catchError(this.handleError));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6011 次 |
| 最近记录: |