Greetings! Upon executing this code, I encountered an error related to the map() method. Despite its apparent simplicity, the issue persists.
var div_usuarios = document.querySelector('#usuarios');
var usuarios = [];
fetch('https://jsonplaceholder.typicode.com/users')
.then(data => data.json())
.then(users=> {
usuarios = users.data;
console.log(usuarios);
usuarios.map((user, i)=>{
let nombre = document.createElement('h2');
nombre.innerHTML = i + user.first_name + " " + user.last_name;
div_usuarios.appendChild(nombre);
})
});
Is there a solution to rectify this issue?
Interestingly, the code mirrors that of an online course I am currently undertaking, yet it fails to function correctly for me!