ここで私が達成しようとしているのは、getGeoLocationOfUser()を呼び出しています。私はユーザーのジオロケーションを返すと仮定しています。何らかのエラーがあります。typescript関数が値を返すためにエラーをスローする
以上の関数はエラーをスローしています宣言された型が 'void'でも 'any'でもない関数は値を返す必要があります。
public userGeolocation={latitude:null,longitude:null}
getGeoLocationOfUser():{latitude:any,longitude:any}{
this.geolocation.getCurrentPosition().then((resp) => {
this.userGeolocation.latitude=resp.coords.latitude;
this.userGeolocation.longitude=resp.coords.longitude;
console.log(this.userGeolocation);
localStorage.setItem('userGeoLocation',JSON.stringify(this.userGeolocation));
return this.userGeolocation;
//saving geolocation of user to localStorage
}).catch((error) => {
console.log('Error getting location', error);
return this.userGeolocation;
});
}
私はここで非常に基本的な考え方.ANYヘルプは理解されるであろうが欠落している可能性があります。
十分なフェア。@ロブ私はissues..Peopleと答えの束があったので、多くのコメントを入れてしまった矢印関数が値を返すのに..ラッシュさFGITW –