I have following method :
request(url: string|Request, options?: RequestOptionsArgs): Observable<Response> {
this.customOptions = options;
return this.authService.approveTokenExpiration()
.flatMap((res) => {
if (!(res.json().data.error) && !(res.error)) {
console.log("addedHeaders");
this.addAuthHeader();
console.log(this.customOptions);
} else {
// return this.authService.refreshToken()
// .flatMap(() => {
// this.addAuthHeader();
// return super.request(url, this.customOptions);
// });
}
})
.flatMap(res => {
return super.request(url, this.customOptions);
});
}
and approveTokenExpiration method:
public approveTokenExpiration(): Observable<any> {
let header = new Headers();
header.append('Authorization', this.formTokenHeaderValue());
console.log(header);
let options = new RequestOptions({headers: header});
return this.http.get(Constants.SERVER_URL, options)
.map(res => {
return res;
})
.catch(err => {
return err;
});
}
I'm getting such error when i'm trying to chain my rxjs requests:
ERROR in [at-loader] ./src/app/auth/intercept/auth.interceptor.ts:18:16 TS2345: Argument of type '(res: any) => void' is not assignable to parameter of type '(value: any, index: number) => ObservableInput<{}>'. Type 'void' is not assignable to type 'ObservableInput<{}>'.
How to chain this request properly? Do FlatMap chain both .map() and .error() methods? Can i chain requests in this way? Because i need to return Observable from my request method (its custom Http implementation) to let users .subscribe on this.