Sigo recibiendo el siguiente error cuando intento ejecutar una solicitud GET de Rapid API
Uncaught (in promise) ReferenceError: Cannot access 'getData' before initialization const RAPIDAPI_KEY = import.meta.env.VITE_RAPIDAPI_KEY; const GEOLOCATION_URL = "https://ip-geo-location.p.rapidapi.com/ip/check?format=json"; const GEOLOCATION_HOST = "ip-geo-location.p.rapidapi.com"; const getData = async(url, host) => { const response = await fetch(url, { method: "GET", headers: { accept: "application/json", "x-rapidapi-host": host, "x-rapidapi-key": RAPIDAPI_KEY } }) if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`) } return await response.json(); } const runApiQueries = async() => { // GET CITY NAME const getData = await getData(GEOLOCATION_URL, GEOLOCATION_HOST); console.log(getData); } runApiQueries();el problema es la linea
const getData = await getData(GEOLOCATION_URL, GEOLOCATION_HOST);debería haber sido
const data = await getData(GEOLOCATION_URL, GEOLOCATION_HOST);Bajo ninguna circunstancia, no debe especificar el nombre de la variable igual que la función o cualquier otro identificador definido.