Using axios to fetch api data:
fetchData () {
axios.get(globalConfig.OFFERS_URL)
.then((resp) => {
this.offersData = resp.data
console.log(resp)
})
.catch((err) => {
console.log(err)
})
}
Data function:
data () {
return {
offersData: {}
}
}
Now i can use fetched data in my template, like so: {{ offersData.item[0].id }}
But can i set the fetched data in a data function:
data () {
return {
offersData: {},
id: this.offersData.item[0].id
}
}
It's not working for me, is that even possible to store axios get's response in a data function?