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);
}
);
так работает
export const fetchIataViaGeo = createAsyncThunk(
'iata/fetchIataViaGeo',
async () => {
const res = await axios.get(
`https://airlabs.co/api/v9/nearby?lat=55.22&lng=22.23&distance=45&api_key=...`
);
console.log(res.data.response.airports);
return await res.data.response.airports;
};
}
);
undefined- во втором случае - возвращается, поэтому и работает – Grundy Dec 28 '23 at 23:00