我希望在HTTP调用超时事件发生时向用户提供反馈。
我尝试过以下这种方式:
我尝试过以下这种方式:
return this._http
.post(apiUrl + 'Search/Everything', params, {withCredentials: true, headers: this.headers})
.timeout(5000, this._feedbackService.error("Custom error message"))
.map((response: Response) => response.json().data);
但是这会在HTTP调用一开始就触发反馈服务。
当超时时间到达时,我该如何触发该服务?
rxjs/add/operator/timeoutWith
之外,我还需要导入什么才能使其工作?(即 "Rx." 部分)。 - Glenn Utterimport "rxjs/add/observable/defer"
和import "rxjs/add/observable/throw"
。 - cartant