Inconsistent wixWindow.getCurrentGeolocation

Hello Team. I apologize for posting this second time. My post was not visible and I dont think I would get a reply for that.

I am using wixWindow.getCurrentGeolocation to get the current location of my device. However, this sometimes gives undefined values as results. Can someone please help me ?

Here is my code. Please let me know if the promise is not resolved

import wixLocation from ‘wix-location’;
import wixData from ‘wix-data’;
import wixWindow from ‘wix-window’;
$w.onReady(function () {

getDetails(); 

});

async function getDetails() {

$w("#repeater1").hide(); 

let latitude; 
let longitude;  

wixWindow.getCurrentGeolocation() 
	.then(async(obj) => { 
		latitude = obj.coords.latitude; // 32.0971036 
		longitude = obj.coords.longitude; // 34.774391099999995 

	}) 
	.catch((error) => { 
		let errorMsg = error; 
	}); 

await wixData.query("Service") 
	.find() 
	.then((results) => { 
		var list = []; 
		let filteredResults = results.items; 
		console.log("list is " + filteredResults); 
		for (var i = 0; i < filteredResults.length; i++) { 
			list[i] = filteredResults[i].title; 
		} 
		console.log(filteredResults); 
		var removed = []; 
		var duplicates = list.reduce(function (acc, el, i, arr) { 
			if (arr.indexOf(el) !== i && acc.indexOf(el.trim()) < 0) acc.push(el); 
			return acc; 
		}, []); 
		console.log("Duplicates are" + duplicates); // = 1,3 (actual array == [1, 3]) 
		for (var i = 0; i < filteredResults.length; i++) { 
			if (duplicates.includes(filteredResults[i].title)) { 
				if (!removed.includes(filteredResults[i].title)) { 
					removed.push(filteredResults[i].title); 
					filteredResults.splice(i, 1); 
				} 

			} 
		} 
		$w("#repeater1").data = filteredResults; 
		console.log(filteredResults); 
		$w("#repeater1").onItemReady(($w, itemData, index) => { 
			console.log(itemData); 
			$w("#text15").text = itemData.title; 
			$w("#repeater1").show(); 
			$w("#container1").onClick((event, $w) => { 
				const data = $w("#repeater1").data; 
				let service = data.filter(item => item._id === event.context.itemId); 
				console.log("Service is " + service[0].title); 
				var loc = service[0].title; 
				loc = loc.replace(" ", "-"); 
				console.log(loc); 
				if (latitude == undefined || longitude == undefined) { 
					latitude = 41.263906; 
					longitude = -95.860830; 
				} 
				wixLocation.to("/getorgs/" + loc + "/0/0/" + latitude + "/" + "/" + longitude); 
				//wixLocation.to("/getorgs/" + loc+"/0/0/"); 
				//wixLocation.to("/getorgs/"+loc+"/1/10"); 
			}); 
		}); 
	});