기본 각도 2 HTTP 서비스를 무시하는 사용자 지정 http 서비스가 있습니다. 이 서비스는 사용자 정의 기본 옵션을 설정하고 요청 시작시 로더를 설정하고 요청 완료시 로더를 숨 깁니다.각도 2 http catch 관찰 가능 문제
서버에서 승인되지 않은 오류 (401, 403)를받은 경우 사용자를 로그인 페이지로 리디렉션하는 기능도 추가하고 싶습니다. 예를 들어 아래에있는 내 HTTP 메소드
get(url: string, options?: RequestOptionsArgs): Observable<any> {
this.setLoadingStatus();
options = this.prepareOptions(options);
let that = this;
return super.get(url, options)
.map(res => {
this.clearLoadingStatus();
return res.json();
})
.catch(function (err) {
//redirects user to login and display alert
that._gs.alertUnauthorized();
return Observable.empty();
});
}
그러나 브라우저 IE에서 테스트가 인증되지 않은 요청의 경우 401을 반환 보호 된 페이지에 대한 요청을 할 때, 그것은 오류가 아래의 로그인 페이지하지만 콘솔 디스플레이로 리디렉션 도다이다
GET http://localhost:49547/api/protected/ 401 (Unauthorized)
EXCEPTION: Observable_1.Observable.empty is not a function
ORIGINAL STACKTRACE:
TypeError: Observable_1.Observable.empty is not a function
아무도 안내 할 수 있습니까?
는'super.get()지도 ((고해상도) => {}, (ERR) =>를 {}) 시도,'구문을.? –