4
我想在HTTP調用發生超時事件時向用戶提供反饋。Angular 2 rxjs超時回調
我嘗試這樣做:
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調用時將觸發反饋服務。
超時啓動時如何啓動服務?
對不起。我回答了這個問題,然後意識到我會誤解這個問題。我已經更新了答案。 – cartant
除了'rxjs/add/operator/timeoutWith'之外,我還需要導入哪些內容才能使其工作? (即「Rx。」部分)。 –
您將需要'import「rxjs/add/observable/defer」'和'import「rxjs/add/observable/throw」'。 – cartant