export const fetchIataViaGeo = createAsyncThunk(
'iata/fetchIataViaGeo',
async () => {
const error = () => {
alert('Sorry, we could not find your location. Please enter manually.');
};
const succuess = async (position) => {
const lat = position.coords.latitude;
const lng = position.coords.longitude;
const res = await axios.get(
`https://airlabs.co/api/v9/nearby?lat=${lat}&lng=${lng}&distance=45&api_key=...`
);
console.log(res.data.response.airports);
return await res.data.response.airports;
};
navigator.geolocation.getCurrentPosition(succuess, error);
}
);
This may be due to the fact that I’m returning it in the wrong place, but I don’t understand where it’s needed.when i try it without geolocation request,it work well