codelikepro22/place-to-stay

NetworkError when attempting to fetch resource.

Opened this issue · 0 comments

with the of :
useEffect(() => {
const storedLocation = JSON.parse(
localStorage.getItem(currentUser.id)
)?.location;
if (!lng && !lat && !storedLocation?.lng && !storedLocation?.lat) {
fetch('https://ipapi.co/json')
.then((response) => {
return response.json();
})
.then((data) => {
dispatch({
type: 'UPDATE_LOCATION',
payload: { lng: data.longitude, lat: data.latitude },
});
});
}
}, []);

the fetch method gives this error : NetworkError when attempting to fetch resource.