tengo este problema, busco imágenes de una API y las almaceno en una matriz. Cuando registro la matriz, tengo el resultado, pero cuando quiero ingresar un elemento de la matriz, tengo 'indefinido'
'''
punto_entrada = "http://localhost:8000/api/v1/titles/"
function get_data(genre, page) { let datas = []; fetch(entry_point + '?genre=' + genre + '&page=' + page) .then(res => res.json()) .then(data => data.results.forEach(element => { datas.push(element) })); return datas; } let array = get_data('Action', 1) console.log(array) ======> log the array correctly console.log(array[0]) =====> returns 'undefined' '''