2👍
✅
The arrow function is to blame, I believe. Convert getAllItemsFromDb to a function
function:
methods: {
getAllItemsFromDb() {
const url = 'https://localhost:44339/ListAll';
axios.get(url, {
headers: {
'Content-Type': 'application/json'
}
}).then((response) => {
this.itemListModel = response.data
})
}
}
1👍
In your getAllItemsFromDb function you are awaiting the result of axios.get(). As a result you don’t need the .then() block. Try this:
getAllItemsFromDb: async () => {
const url = 'https://localhost:44339/ListAll';
const response = await axios.get(url, {
headers: {
'Content-Type': 'application/json'
}
});
this.itemListModel = response.data;
}
Source:stackexchange.com