Property 'text' does not exist on type 'Object' HttpClient

Hi,

Today I’ve updated my project to Angular 5 and ionic 3.9.2 and my injectable service to manage http connections has stopped to work.

import {HttpClient} from “@angular/common/http”;

constructor(private http: HttpClient) {
}

obtainData(url){
return this.http.get(url)
.toPromise()
.then(response => {
console.log(response.json())
}).catch(this.handleError);
}

With HttpClient library(Http library is deprecated) the transpile shows this error

Property ‘json’ does not exist on type ‘Object’.

Other properties like .text(), .headers also not work

If I change HttpClient to Http all works properly

What I’m doing wrong?

1 Like

look here the same problem with solution: https://github.com/angular/angular/issues/5273