async function position() {
const pos = await new Promise((resolve) => {
navigator.geolocation.getCurrentPosition(resolve);
});
return {
long: pos.coords.longitude,
lat: pos.coords.latitude,
accuracy: pos.coords.accuracy,
altitude: pos.coords.altitude,
heading: pos.coords.heading,
speed: pos.coords.speed,
timestamp: pos.timestamp
}
Как вывести в консоль данные с этой асинхронной функции? Через простой console.log(position()); возращается Promise pending
position().then(c => console.log(c))– andreymal Dec 25 '21 at 15:11