You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When attempting to access the current location using the build browser navigator function, an error is thrown stating that navigator is undefined. To resolve this issue, the following code was added: if (typeof navigator !== 'undefined'). However, after implementing this fix, the application now throws an error stating that routeConfiguration is not a function
Steps to reproduce the behaviour:
Create a new file called useCurrentLocation.js with this code
import { types as sdkTypes } from '../util/sdkLoader';
const { LatLng } = sdkTypes;
export const useCurrentLocation = async () => {
if (typeof navigator !== 'undefined') {
if (!('geolocation' in navigator)) {
throw new Error('Geolocation not available in the browser');
}
const options = {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0,
};
try {
const position = await new Promise((resolve, reject) => {
navigator?.geolocation?.getCurrentPosition(resolve, reject, options);
});
return new LatLng(position.coords.latitude, position.coords.longitude);
} catch (error) {
console.log('error->>>Location', error);
return error.message;
}
} else {
return;
}
};
2.Call the function in Searchpage.duck.js to access the current Location
When attempting to access the current location using the build browser navigator function, an error is thrown stating that navigator is undefined. To resolve this issue, the following code was added:
if (typeof navigator !== 'undefined')
. However, after implementing this fix, the application now throws an error stating that routeConfiguration is not a functionSteps to reproduce the behaviour:
2.Call the function in Searchpage.duck.js to access the current Location
Expected behavior This should run without error when
npm run dev-server
Screenshots
The text was updated successfully, but these errors were encountered: