Getting longitude and latitude best practice

i’m trying to get user longitude and latitude at the login … so i want to know what the best way to get them without error?
my code

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  responseData: any;
  loginData = {
    "identity": "",
    "password": "",
    "latitude": "",
    "longitude": ""
  };
  // public let userLogData = new FormData();
  // loginData.append('identity', userLogData.identity)

  userData: any;
  forgotpage = ForgotpassePage
  constructor(public navCtrl: NavController,
    public authService: AuthServiceProvider,
    private Facebook: Facebook,
    private storage: Storage,
    private Geolocation: Geolocation,
    private lodaingCtrl: LoadingController,
    public Platform : Platform,
    public translate: TranslateService) {


  }

  login() {
    const loading = this.lodaingCtrl.create({
      content: 'Signing you in ...'
    });
    loading.present();
    this.Geolocation.getCurrentPosition().then(go => {
      this.userData.longitude = go.coords.longitude;
      this.userData.latitude = go.coords.latitude;
    }).catch();

    this.authService.logData(this.loginData).subscribe((loginresult: any) => {
      this.responseData = loginresult;


      if (this.loginData = this.responseData) {
        loading.dismiss();
        localStorage.setItem('loginData', JSON.stringify(this.loginData));
        this.navCtrl.setRoot(AppHomePage);
        // console.log(this.responseData);

      } else {}
    }, (err) => {
      loading.dismiss();
      alert('Please Enter Registered Email and Password');

    });

  }

hello,

you have an error. Why you do not show it?

So I see in my glass ball…use == for comparing in if … do…

Best regards, anna-liebt

Hi anna … thank you for reply
this the error

That’s not an error, that’s an image. Posting text as images is rude.

Don’t use any. Don’t give your object properties names that clash with classes. Do initialize all of them at the point of declaration. Failure on that last point is causing your problem.