Installation
Add vue-api-query
dependency to your project:
yarn add vue-api-query
npm install vue-api-query
Nuxt
Create a plugin ~/plugins/vue-api-query.js
~/plugins/vue-api-query.js
// inject global axios instance as http client to Model
import { Model } from 'vue-api-query'
export default function (ctx, inject) {
Model.$http = ctx.$axios
}
And register it on nuxt.config.js
nuxt.config.js
export default {
plugins: [
'~plugins/vue-api-query'
],
}
Vue
Set up on src/main.js
src/main.js
import axios from 'axios'
import { Model } from 'vue-api-query'
// inject global axios instance as http client to Model
Model.$http = axios