问题
with this code I can catch all the exceptions, except the when the server is anavailable. Do you have any idea about how should be handle ?
return this.http.post<User>(this._appSetting.ebit.base_url "rested/login/login", JSON.stringify(params), httpOptions)
.pipe(catchError(this.handleError));
回答1:
You can use the timeout()
operator to catch a timeout. It's measured in milliseconds so 10000
would be 10 seconds.
return this.http.post<User>(this._appSetting.ebit.base_url "rested/login/login", JSON.stringify(params), httpOptions)
.pipe(timeout(10000), catchError(this.handleError));
来源:https://stackoverflow.com/questions/51405688/angular6-catch-timeout-error