@nuxtjs/axios
Advanced tools
Comparing version 4.0.1 to 4.1.0
@@ -5,2 +5,22 @@ # Change Log | ||
<a name="4.1.0"></a> | ||
# [4.1.0](https://github.com/nuxt-community/axios-module/compare/v4.0.1...v4.1.0) (2017-09-06) | ||
### Bug Fixes | ||
* inject $axios in current ctx ([356b31f](https://github.com/nuxt-community/axios-module/commit/356b31f)) | ||
### Features | ||
* add options.init ([8e0c0e8](https://github.com/nuxt-community/axios-module/commit/8e0c0e8)) | ||
### Performance Improvements | ||
* move init outside of plugin ([bcd4710](https://github.com/nuxt-community/axios-module/commit/bcd4710)) | ||
<a name="4.0.1"></a> | ||
@@ -7,0 +27,0 @@ ## [4.0.1](https://github.com/nuxt-community/axios-module/compare/v4.0.0...v4.0.1) (2017-09-04) |
@@ -99,3 +99,8 @@ import Axios from 'axios' | ||
export default (ctx, inject) => { | ||
// Custom init hook | ||
<% if (options.init) { %> | ||
const initHook = <%= serialize(options.init).replace('init(', 'function(').replace('function function', 'function') %> | ||
<% } %> | ||
export default <% if (options.init) { %>async<% } %>(ctx, inject) => { | ||
const { app, store, req } = ctx | ||
@@ -130,3 +135,3 @@ | ||
<% if(options.credentials) { %> | ||
<% if (options.credentials) { %> | ||
// Send credentials only to relative and API Backend requests | ||
@@ -172,3 +177,3 @@ axios.interceptors.request.use(config => { | ||
<% } %> | ||
// Error handler | ||
@@ -183,6 +188,12 @@ axios.interceptors.response.use(undefined, errorHandler.bind(ctx)); | ||
// Inject axios to the context as $axios | ||
ctx.$axios = axios | ||
inject('axios', axios) | ||
<% if (options.init) { %> | ||
await initHook(axios, ctx) | ||
<% } %> | ||
// Setup axios helpers | ||
setupHelpers(axios) | ||
} |
{ | ||
"name": "@nuxtjs/axios", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"description": "Secure and easy axios integration with Nuxt.js", | ||
@@ -14,3 +14,4 @@ "license": "MIT", | ||
"test": "npm run lint && jest", | ||
"release": "standard-version && git push --follow-tags && npm publish" | ||
"release": "standard-version && git push --follow-tags && npm publish", | ||
"prepare": "npm run test" | ||
}, | ||
@@ -17,0 +18,0 @@ "eslintIgnore": [ |
@@ -117,2 +117,4 @@ # Axios Module | ||
> **NOTE:** If directing requests at a url protected by CloudFlare's CDN you should set this to false to prevent CloudFlare from mistakenly detecting a reverse proxy loop and returning a 403 error. | ||
### `redirectError` | ||
@@ -124,7 +126,5 @@ - Default: `{}` | ||
```js | ||
{ | ||
axios: { | ||
redirectError: { | ||
401: '/login' | ||
} | ||
axios: { | ||
redirectError: { | ||
401: '/login' | ||
} | ||
@@ -154,2 +154,15 @@ } | ||
### `init` | ||
- Default: `null` | ||
Function `init(axios, ctx)` to do additional things with axios. Example: | ||
```js | ||
axios: { | ||
init(axios, ctx) { | ||
axios.defaults.xsrfHeaderName = 'X-CSRF-TOKEN' | ||
} | ||
} | ||
``` | ||
### `errorHandler` | ||
@@ -156,0 +169,0 @@ - Default: (Return promise rejection with error) |
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
25705
215
294