How can I pass fetched data to array called users? I've tried using this.users = data.data, then console.log(users) and nothing is showing up.
Also I am trying to map response, I am getting error in console Uncaught TypeError: fetchData.map is not a function
const users = [];
const fetchData = () => {
axios.get('https://reqres.in/api/users')
.then(({data}) => {
this.users = data.data;
console.log(data);
})
}
fetchData();
const mapUsers = fetchData.map((item) => {
return {
avatar: item.avatar
}
})