0👍
your check_permissions
is having the state: prompt
so the code will not go into your if block here
if (check_permissions.state === "granted") { //<------------------- false
this.error_flag = false;
this.error_message = "";
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(this.showPosition); //<--- why not passing a param here? your function showPosition await a parameter
this.error_flag = false;
this.error_message = "";
} else {
this.error_flag = true;
this.error_message = "Perangkat anda tidak mendukung GPS";
}
} else // <---------- your landing here
this.error_flag = true;
this.error_message = "Silahkan aktifkan GPS terlebih dahulu";
}
then your code ends.
there is btw no need to await a synchronous function like here
// no need to await since navigator.permission is not async at all
const check_permissions = await navigator.permissions.query({
name: "geolocation",
});
Source:stackexchange.com