How can I modify my http call to native ionic v3 http call?

Viewed 26

Please someone can help me, I have this provider in ionic:

constructor(public http: HttpClient) {
  }

   getNearbyplaces(geo:any){
    //  console.log("geo",geo)
      return this.http.get('https://maps.googleapis.com/maps/api/place/nearbysearch/json?location='+geo+'&radius=50&key=MY_API_KEY')
        .map(res => res );
    } 

Now,I am facing CORS issues when run my app in my android device, then I have read that a good option to avoid this is using the native HTTP call, but its syntax is different and I do not understand it.

Here is my module.ts code snippet where I call the fucntion of my provider:

getNearbylocation(){
    this.locationProvider.getNearbyplaces(this.latitude + "," + this.longitude).subscribe(
        locationList=>{
          this.nearByList = locationList["results"];
          console.log("Printing map"); //to check api hc
          this.loadMap()
          this.loading.dismissAll();
        },err =>{
          console.log("error in map");
          this.loading.dismissAll();
        },
        () =>{
    })
  }

Can you explain me how to change my code from http call to http native call? Thank you

I have already read some answers but no one corresponds to my needs. I am a beginner in ionic and any help would be appreciated

0 Answers
Related