Ionic geolocation lat lon is undefined

Hi, guys, I’m stuck in a condition.
I’m trying to send the lat and lon value to the backend but the backend is getting “undefined value” when I try from android emulator but when I try it from ionic browser then the values are passing fine.
I’ve also used android permission to allow the location.
below is the code I’m using:

ts-

 ionViewDidLoad() {
    console.log('ionViewDidLoad EngineerPage');
    this.geolocation.getCurrentPosition().then((resp)=>{
      this.lat = resp.coords.latitude;
      this.lon = resp.coords.longitude;
      console.log(this.lat);
      console.log(this.lon);
    }).catch((error)=>{
      console.log('Error getting location', error)
    })
  }
sendData(){
 var form = new FormData();
    form.append("id", this.uid);
    form.append("name", this.name);
    form.append("contact", this.contact);
    form.append("remark", this.remark);
    form.append('lat', this.lat);
    form.append('lon', this.lon);

    this.http.post('http://myapi.php', form)
      .subscribe(data => {
        console.log(data['_body']);
        var dataFine = JSON.parse(data['_body']);
        console.log(dataFine);
        if (dataFine.status == 0) {
          this.commonTasksObj.displaySimpleToast("Data Sent");
      // }, error => { });
  }
}
      )}
}

when from emulator:

when from browser(chrome):