I'm trying to take data from the API and put it in a array so I can manipulate it. I created a function that adds data from the API to a array . But the data from the array is only visible in the browser console, not in the .js file. Also i cant do forEach from js but can from console :/.
let users = [];
async function getUsersData() {
try {
const url = 'https://jsonplaceholder.typicode.com/users'
const response = await fetch(url)
const data = await response.json()
settData(data)
} catch (eror) {
console.log('jbg puce')
}
}
function settData(data) {
users.push(...data)
}
getUsersData()
console.log(users)