Socket
Socket
Sign inDemoInstall

@nuxtjs/axios

Package Overview
Dependencies
Maintainers
3
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuxtjs/axios - npm Package Compare versions

Comparing version 5.0.0-alpha.0 to 5.0.0-alpha.1

10

CHANGELOG.md

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

<a name="5.0.0-alpha.1"></a>
# [5.0.0-alpha.1](https://github.com/nuxt-community/axios-module/compare/v5.0.0-alpha.0...v5.0.0-alpha.1) (2018-01-28)
### Features
* integrate with nuxt progress bar ([41a0964](https://github.com/nuxt-community/axios-module/commit/41a0964))
<a name="5.0.0-alpha.0"></a>

@@ -7,0 +17,0 @@ # [5.0.0-alpha.0](https://github.com/nuxt-community/axios-module/compare/v4.5.2...v5.0.0-alpha.0) (2018-01-28)

1

lib/module.js

@@ -41,2 +41,3 @@ const chalk = require('chalk')

proxyHeaders: true,
progress: true,
proxyHeadersIgnore: ['accept', 'host'],

@@ -43,0 +44,0 @@ debug: false,

@@ -75,4 +75,3 @@ import Axios from 'axios'

})
}
<% } %>
}<% } %>

@@ -89,5 +88,48 @@ <% if (options.credentials) { %>

})
}
<% } %>
}<% } %>
<% if (options.progress) { %>
const setupProgress = (axios, ctx) => {
if (process.server) {
return
}
// A noop loading inteterface for when $nuxt is not yet ready
const noopLoading = {
finish: () => { },
start: () => { },
fail: () => { },
set: () => { }
}
const $loading = () => window.$nuxt ? window.$nuxt.$loading : noopLoading
let currentRequests = 0
axios.onRequest(() => {
currentRequests++
})
axios.onResponse(() => {
currentRequests--
if (currentRequests <= 0) {
currentRequests = 0
$loading().finish()
}
})
axios.onError(() => {
currentRequests--
$loading().fail()
})
const onProgress = e => {
const progress = ((e.loaded * 100) / (e.total * currentRequests))
$loading().set(progress)
}
axios.defaults.onUploadProgress = onProgress
axios.defaults.onDownloadProgress = onProgress
}<% } %>
export default (ctx, inject) => {

@@ -131,2 +173,3 @@ const axiosOptions = {

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

@@ -133,0 +176,0 @@ // Inject axios to the context as $axios

2

package.json
{
"name": "@nuxtjs/axios",
"version": "5.0.0-alpha.0",
"version": "5.0.0-alpha.1",
"description": "Secure and easy axios integration with Nuxt.js",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -35,5 +35,20 @@ <p align="center">

## Features
✓ Automatically set base URL for client & server side
✓ Exposes `setToken` function to `$axios` so we can easily and globally set authentication tokens
✓ Throws _nuxt-friendly_ errors and optionally redirect on specific error codes
✓ Automatically enables `withCredentials` when requesting to base URL
✓ Proxy request headers in SSR (Useful for auth)
✓ Fetch Style requests
✓ Automatically integrate with Nuxt.js progress bar
# Table of Contents
* [Features](#features)
* [Setup](#setup)

@@ -54,2 +69,3 @@ * [Usage](#usage)

* [browserBaseURL](#browserbaseurl)
* [progress](#progress)
* [credentials](#credentials)

@@ -61,11 +77,2 @@ * [debug](#debug)

## Features
* Automatically set base URL for client & server side
* Exposes `setToken` function to `$axios` so we can easily and globally set authentication tokens
* Throws _nuxt-friendly_ errors and optionally redirect on specific error codes
* Automatically enables `withCredentials` when requesting to base URL
* Proxy request headers in SSR (Useful for auth)
* Fetch Style requests
## Setup

@@ -76,3 +83,3 @@

```bash
>_ yarn add @nuxtjs/axios
yarn add @nuxtjs/axios
```

@@ -83,3 +90,3 @@

```bash
>_ npm install @nuxtjs/axios
npm install @nuxtjs/axios
```

@@ -170,2 +177,8 @@

})
$axios.onError(error => {
if (error.code === 400) {
redirect('/400')
}
})
}

@@ -299,2 +312,8 @@ ```

### `progress`
* Default: `true`
Integrate with Nuxt.js progress bar to show a loading bar while making requests. (Only on browser, when loading bar is available.)
### `credentials`

@@ -301,0 +320,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc