I have the following code
import {HttpClient} from '@ngular/common/http';
private httpClient: HttpClient;
do_request(method: string,
url: string,
headers?: HttpHeaders,
content?: string,
contentType?: string): Observable<MyResponse>{
let options = {
observe: 'response' as 'response',
responseType: 'text' as 'text',
headers: headers,
body: content:
}
return this.httpClient.request(method, url, options)
.map(res=> new MyResponse(res.status, res.body))
.catch(err=>Observable.throw(new MyResponse(err.status)));
}
This code is giving me the following error
error TS2322: Type 'Observable' is not assignable to type 'Observable'. Property 'source' is protected but type 'Observable' is not a class derived from 'Observable'
I'm using Rxjs 5.4.3, Angular 4.4.3 and TypeScript 2.5.3.
I've found several possible error sources and tried the suggested solutions with no luck:
- Typescript version(I downgraded to 2.3 with similar results)
- Importing a package that also has a dependency on rxjs using npm link (I installed it locally, with same result).
I will appreciate any suggestion on how to fix this issue.
catch
block? – Meir