I'm encountering an issue while attempting to populate my empty object with data received from a JSON server API. The problem persists on the same line repeatedly:
Uncaught (in promise) TypeError: Cannot set property 'itemListModel' of undefined at eval
Here is my code snippet:
data: function() {
return {
itemListModel: {}
}
}
methods: {
getAllItemsFromDb: async () => {
const url = 'https://localhost:44339/ListAll';
await axios.get(url, {
headers: {
'Content-Type': 'application/json'
}}).then((response) => {
this.itemListModel = response.data
})
}
}
computed : {
itemResultsFromDB: function(){
return this.itemListModel
}
}
I've also referred to a similar question here: Uncaught (in promise) TypeError: Cannot set property of undefined with Axios
Despite that, I can't seem to identify what's causing the discrepancy in my implementation?