Sorry if my terminology isn't quite right, I'm still new to fullstack development.
Hello there! Currently, I am attempting to retrieve all users from my database. Upon executing the get()
request, the client is receiving an OK
response as shown in the image below:
https://i.sstatic.net/DPVqk.png
The issue arises when I attempt to access the .data
, it returns undefined
.
Below is a snippet of my Vue Component
:
import UserService from '@/services/UsersService.js'
export default {
data () {
return {
users: null
}
},
async mounted () {
// Performing a GET request to fetch all users.
this.users = UserService.index().data
console.log('The response is OK', await UserService.index())
console.log('attempting to access .data results in ', await this.users)
}
}
Function index() definition:
import Api from '@/services/Api'
export default {
index () {
return Api().get('users')
}
}
Everything seems to be functioning correctly, except for the fact that I am getting back undefined
data...