[Vuejs]-Computed property not reading data initialized in created

2👍

try something like this

getSomething(){
 return axios.get(...) { this.info = response.data }
}

then you can use the promise returned in created method like this….

created () {
  getSomething().then( () => {
    doSomething()
  }}
}

2👍

You could utilise Vuex‘ state management…

Vuex has :

  • Dispatches

  • Actions

  • Mutations

  • Getters

What i am thinking is, on your page load, map an action to the store that makes a call to your axios service and after it returns, commit a mutation that stores the response to the store…
then you can map the state to your component and retrieve the data.

This might not be the quickest answer but if you are expecting to need the response data from the axios request, it might be worth putting it into some sort of state management 🙂

Leave a comment