Merge dev@latest into dev
This commit is contained in:
16 files changed
+445
-101
No files matched your search
@@ -0,0 +1,24 @@
|
||||
function getLocation() {
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(success, error);
|
||||
}
|
||||
}
|
||||
|
||||
function success(position) {
|
||||
const { latitude, longitude } = position.coords;
|
||||
|
||||
fetch("api/location" , {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({ latitude, longitude })
|
||||
}).then(res => res.json())
|
||||
.then(data => {
|
||||
console.log(data.results[0].formatted_address);
|
||||
})
|
||||
}
|
||||
|
||||
function error(err) {
|
||||
console.error("Geolocation error: ", err);
|
||||
}
|
||||
Reference in new issue
Block a user