I need to modify the following vue.js code snippet. Here is the original code:
computed: {
...mapGetters('user/auth', ['Id']),
},
async mounted() {
await this.doFetchCustomer(this.Id)
},
methods: {
async doFetchCustomer(Id) {
const app = { $axios: this.$axios }
const datas = (await customerApi.getData(app, Id)) || []
console.log(datas)
},
},
I attempted to convert this code to use nuxt's asyncData
, but my solution below did not work. How can I properly transform it?
computed: {
...mapGetters('user/auth', ['Id'])
},
async asyncData({$axios}) {
const datas = (await customerApi.getData($axios, this.Id )) || [];
console.log(datas);
return {datas}
}