This library makes Nuxt.js possible to use mixin for asyncData()/fetch() and provide some helpful features.
Install
npm i nuxtend
Mixin
const m = async { // works! return commonData: 'data' } mixins: m async { return {} }
this
.
methods can be used on asyncData/fetch via This feature enables you to call a vuex action in same syntax anywhere. Of course you can call non vuex action methods also.
const mixinA = methods: ... mixins: mixinA async { const books = await this const audios = await this return books audios } { this } methods: ...
Abstraction of calling api and actions. (since 0.2.0)
nuxtend: actions: 'apple' 'me/banana' async { // if 'apples/get' action is defined call it, if not call $axios.get('/apples/10') const res = await this // and also below functions can be used as well. // - action: 'apples/getList' api: this.$axios.get('/apples', {params: {status: 'dropped'}}) // this.getAppleList({status: 'dropped'}) // - action: 'apples/create' api: this.$axios.post('/apples', {status: 'dropped'}) // this.postApple({status: 'dropped'}) // - action: 'apples/update' api: this.$axios.put('/apples/10', {status: 'dropped'}) // this.putApple({id: 10, params: {status: 'dropped'}}) // - action: 'apples/delete' api: this.$axios.delete('/apples/10') // this.deleteApple(10) // - action: 'me/bananas/get' api: this.$axios.get('/me/bananas/10') // this.getBanaa(1) return apple: resdata }