Entonces, cuando le damos a esta función getApiData algo para obtener, queremos que realmente devuelva los datos obtenidos. De momento devuelve "indefinido" y no entendemos por qué.
console.log(name) if (`${restVar}` != `GET`) { bodyData = JSON.stringify(bodyData); } fetch(`${url}`, { method: `${restVar}`, headers: { 'Content-Type': 'application/json' }, body: bodyData }) .then(response => response.json()) .then(data => { console.log('Success:', data); return data; }) .catch((error) => { console.error('Error:', error) }); }``` Any help would be much appreciated :)