I'm trying to set my empty object with the values I get from my server API, which is a json. But I keep getting an error on the same row, over and over again:
Uncaught (in promise) TypeError: Cannot set property 'itemListModel' of undefined at eval
my code:
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
}
}
Looked att this previous question: Uncaught (in promise) TypeError: Cannot set property of undefined with axios
But I can't see what I am doing differently?