0👍
You’re dealing with Promises in this case. They do not behave like a typical function in JavaScript. I would recommend starting with some basics:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
As to your question, getData
does not return anything, nor is there a getTaskData
in the code you’ve provided.
- [Vuejs]-Watch window.scrollY and router :id in Vue2JS
- [Vuejs]-Excel file corrupted on download with axios vuejs
0👍
As said in the previews response you’re dealing with promise,
You need to wait finishing you’re Ajax request and then you deal with response,
In your code you can do like this
async function getData() {
const response = await axios.get('/task')
return response
}
Call function with callback for the success and failure cases of the Promise
getData()
.then(response => {
console.log(response.data.tasks)
})
.catch(error => {
console.log("ERROR")
})
- [Vuejs]-How does Azure AD and Aspnet Core Identity work together?
- [Vuejs]-How to client-side sort inertia data?
Source:stackexchange.com