I'm trying to apply a function to map each element that my promise return after a fetch request. Somehow I can log the result to the console but I cannot use it further more. Here is my code:
async function init() {
const res = await fetch(`https://jsonplaceholder.typicode.com/users`);
const data = await res.json();
console.log(data);
function getUsersNames (data){
data.map((user, index)=>{
console.log(user[index].name);
})
}
}
init();
and this is a screenshot of my output in the console:
Any help would be great! Thanks