Socket
Socket
Sign inDemoInstall

@nuxtjs/axios

Package Overview
Dependencies
5
Maintainers
3
Versions
86
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.0-rc.2 to 5.0.0

17

CHANGELOG.md

@@ -5,2 +5,19 @@ # Change Log

<a name="5.0.0"></a>
# [5.0.0](https://github.com/nuxt-community/axios-module/compare/v5.0.0-rc.2...v5.0.0) (2018-02-04)
### Bug Fixes
* **progress:** finish on fail ([ea7b569](https://github.com/nuxt-community/axios-module/commit/ea7b569))
### Features
* https option ([#57](https://github.com/nuxt-community/axios-module/issues/57)) ([9ecb547](https://github.com/nuxt-community/axios-module/commit/9ecb547))
* passing options via proxy option ([a923db3](https://github.com/nuxt-community/axios-module/commit/a923db3))
* support retry with axios-retry ([7221cac](https://github.com/nuxt-community/axios-module/commit/7221cac)), closes [#77](https://github.com/nuxt-community/axios-module/issues/77)
<a name="5.0.0-rc.2"></a>

@@ -7,0 +24,0 @@ # [5.0.0-rc.2](https://github.com/nuxt-community/axios-module/compare/v5.0.0-rc.1...v5.0.0-rc.2) (2018-01-29)

21

lib/module.js

@@ -43,3 +43,5 @@ const chalk = require('chalk')

proxyHeadersIgnore: ['accept', 'host'],
proxy: false
proxy: false,
retry: false,
https: false
},

@@ -68,2 +70,14 @@ moduleOptions

// Normalize options
if (options.retry === true) {
options.retry = {}
}
// Convert http:// to https:// if https option is on
if (options.https === true) {
const https = s => s.replace('http://', 'https://')
options.baseURL = https(options.baseURL)
options.browserBaseURL = https(options.browserBaseURL)
}
// Register plugin

@@ -78,3 +92,6 @@ this.addPlugin({

if (options.proxy) {
this.requireModule('@nuxtjs/proxy')
this.requireModule([
'@nuxtjs/proxy',
typeof options.proxy === 'object' ? options.proxy : {}
])
}

@@ -81,0 +98,0 @@

5

lib/plugin.template.js
import Axios from 'axios'
<% if (options.retry) { %>import axiosRetry from 'axios-retry'<% } %>

@@ -122,2 +123,3 @@ // Axios.prototype cannot be modified

$loading().fail()
$loading().finish()
})

@@ -172,3 +174,4 @@

<% if (options.credentials) { %>setupCredentialsInterceptor(axios)<% } %>
<% if (options.progress) { %>setupProgress(axios, ctx)<% } %>
<% if (options.progress) { %>setupProgress(axios, ctx) <% } %>
<% if (options.retry) { %>axiosRetry(axios, <%= serialize(options.retry) %>)<% } %>

@@ -175,0 +178,0 @@ // Inject axios to the context as $axios

{
"name": "@nuxtjs/axios",
"version": "5.0.0-rc.2",
"version": "5.0.0",
"description": "Secure and easy axios integration with Nuxt.js",

@@ -36,8 +36,6 @@ "license": "MIT",

},
"peerDependencies": {
"@nuxtjs/proxy": "^1.1.4"
},
"dependencies": {
"@nuxtjs/proxy": "^1.1.4",
"axios": "^0.17.1",
"axios-retry": "^3.0.1",
"chalk": "^2.3.0",

@@ -48,3 +46,3 @@ "debug": "^3.1.0"

"codecov": "latest",
"eslint": "latest",
"eslint": "^4.17.0",
"eslint-config-standard": "latest",

@@ -58,6 +56,6 @@ "eslint-plugin-import": "latest",

"jest": "latest",
"jsdom": "latest",
"nuxt": "latest",
"jsdom": "^11.6.2",
"nuxt": "^1.3.0",
"standard-version": "latest"
}
}

@@ -43,6 +43,8 @@ <h1 align="center">Axios</h1>

✓ Automatically integrate with Nuxt.js progress bar
✓ Integrated with Nuxt.js Progressbar while making requests
✓ Easily integrate with [Proxy Module](https://github.com/nuxt-community/proxy-module)
✓ Integrated with [Proxy Module](https://github.com/nuxt-community/proxy-module)
✓ Auto retry requests with [axios-retry](https://github.com/softonic/axios-retry)
# Table of Contents

@@ -65,4 +67,6 @@

* [browserBaseURL](#browserbaseurl)
* [https](#https)
* [progress](#progress)
* [proxy](#proxy)
* [retry](#retry)
* [credentials](#credentials)

@@ -175,3 +179,4 @@ * [debug](#debug)

$axios.onError(error => {
if (error.code === 400) {
const code = parseInt(error.response && error.response.status)
if (code === 400) {
redirect('/400')

@@ -308,2 +313,8 @@ }

### `https`
* Default: `false`
If set to `true`, `http://` in both `baseURL` and `browserBaseURL` will be changed into `https://`.
### `progress`

@@ -330,3 +341,3 @@

axios: {
proxy: true
proxy: true // Can be also an object with default options
},

@@ -341,3 +352,3 @@

**Note:** It is not required to manually register `@nuxtjs/proxy` module.
**Note:** It is not required to manually register `@nuxtjs/proxy` module, but it does need to be in your dependencies.

@@ -348,6 +359,20 @@ **Note:** `/api/` will be added to all requests to the API end point. If you need to remove it use `pathRewrite`:

proxy: {
'/api/': { target: 'http://api.example.com', pathRewrite: {'^/api/', ''} }
'/api/': { target: 'http://api.example.com', pathRewrite: {'^/api/': ''} }
}
```
### `retry`
* Default: `false`
Automatically intercept failed requests and retries them whenever posible using [axios-retry](https://github.com/softonic/axios-retry).
By default, number of retries will be **3 times**, if `retry` value is set to `true`. You can change it by passing an object like this:
```js
axios: {
retry: { retries: 3 }
}
```
### `credentials`

@@ -354,0 +379,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc