Seeking assistance with this issue. I am attempting to fetch and save the list of users from an API into an array named "name". However, I have tried using a forEach loop without success. Any suggestions on how to resolve this problem would be greatly appreciated. Thank you!
Edit: I have wrapped the function, but it is still not functioning correctly.
import axios from 'axios'
export default {
data() {
return {
info: null,
name: []
}
},
mounted() {
axios
.get('http://localhost:3000/api/users/', { mode: 'no-cors' })
.then(response => (this.info = response.data))
.then(() => info.data.forEach(element => {
}))
.catch(error => {
console.log(error)
this.errored = true
})
.finally(this.loading = false)
}
}