Angular6 捕获超时错误

Angular6 catch timeout error

使用此代码我可以捕获所有异常,但服务器不可用时除外。 您知道应该如何处理吗?

return this.http.post<User>(this._appSetting.ebit.base_url "rested/login/login", JSON.stringify(params), httpOptions)
                  .pipe(catchError(this.handleError));

您可以使用 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));