Usage
Add Vue plugin
Vue
Now you can access from a component:
// no need to import users: null async { // automatic data return, no need to ".data" thisusers = await this const randomUsers = await this }
Installation
npm install vue-plugin-axios --save
oryarn add vue-plugin-axios
- add
Vue.use
like in code above
This is how you can use with Nuxt.js (client + server):
{ // Vue.use(VueAxios, for some reason did not work VueAxios}
Full API
$get(endpoint[, config])
$delete(endpoint[, config])
$head(endpoint[, config])
$options(endpoint[, config])
$post(endpoint[, data[, config]])
$put(endpoint[, data[, config]])
$patch(endpoint[, data[, config]])
Axios instance:
$axios
or $http
For full response you can use:
const data status statusText headers = await this$axios
Set custom header:
$axios
or multiple:
$axios
Set Authorization token header:
$axios
Delete header: