@nuxtjs/axios
Advanced tools
Comparing version 3.0.1 to 3.1.0
@@ -6,2 +6,13 @@ # Change Log | ||
<a name="3.1.0"></a> | ||
# [3.1.0](https://github.com/nuxt/modules/compare/@nuxtjs/axios@3.0.1...@nuxtjs/axios@3.1.0) (2017-07-31) | ||
### Features | ||
* **axios:** requestInterceptor option (#100) ([fec7a9e](https://github.com/nuxt/modules/commit/fec7a9e)) | ||
<a name="3.0.1"></a> | ||
@@ -8,0 +19,0 @@ ## [3.0.1](https://github.com/nuxt/modules/compare/@nuxtjs/axios@3.0.0...@nuxtjs/axios@3.0.1) (2017-07-25) |
{ | ||
"name": "@nuxtjs/axios", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -138,2 +138,10 @@ import Axios from 'axios' | ||
<% if (options.requestInterceptor) { %> | ||
// Custom request interceptor | ||
const reqInter = <%= serialize(options.requestInterceptor).replace('requestInterceptor(', 'function(') %> | ||
axios.interceptors.request.use( | ||
(config) => reqInter(config, ctx) | ||
) | ||
<% } %> | ||
// Error handler | ||
@@ -140,0 +148,0 @@ axios.interceptors.response.use(undefined, errorHandler.bind(ctx)); |
@@ -129,2 +129,17 @@ # Axios | ||
### `requestInterceptor` | ||
- Default: `null` | ||
Function for manipulating axios requests. Useful for setting custom headers, | ||
for example based on the store state. The second argument is the nuxt context. | ||
```js | ||
requestInterceptor: (config, { store }) => { | ||
if (store.state.token) { | ||
config.headers.common['Authorization'] = store.state.token | ||
} | ||
return config | ||
} | ||
``` | ||
## Helpers | ||
@@ -131,0 +146,0 @@ ### `setHeader(name, value, scopes='common')` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20556
190
242