¿Cómo obtengo mi función getData() para devolver los datos? En este momento obtengo un registro de consola de un objeto de promesa.
function getData() { fetch('//some api url') .then(response => response.json()) .then(data => { return data }) }; export const data = getData(); console.log(data); // returns promise, not actual objectNo puede simplemente esperar el código asíncrono sin await
function getData() { return fetch('//some api url') .then(response => response.json()) .then(data => { return data }) }; getData().then(console.log) function getData() { return fetch('//some api url') .then(response => response.json()) .then(data => { return data }) }; (async () => { const data = await getData() console.log(data) })()