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 4.1.1 to 4.2.1

15

CHANGELOG.md

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

<a name="4.2.1"></a>
## [4.2.1](https://github.com/nuxt-community/axios-module/compare/v4.2.0...v4.2.1) (2017-09-08)
<a name="4.2.0"></a>
# [4.2.0](https://github.com/nuxt-community/axios-module/compare/v4.1.1...v4.2.0) (2017-09-08)
### Features
* pass ctx to errorHandlers ([c70749a](https://github.com/nuxt-community/axios-module/commit/c70749a))
<a name="4.1.1"></a>

@@ -7,0 +22,0 @@ ## [4.1.1](https://github.com/nuxt-community/axios-module/compare/v4.1.0...v4.1.1) (2017-09-06)

8

lib/plugin.template.js

@@ -48,3 +48,3 @@ import Axios from 'axios'

// Set appreciate `statusCode` and `message` to error instance
function errorHandler(error) {
function errorHandler(error, ctx) {
if (error.response) {

@@ -54,3 +54,3 @@ // Error from backend (non 2xx status code)

if (redirectError[error.response.status]) {
this.redirect(redirectError[error.response.status])
ctx.redirect(redirectError[error.response.status])
}

@@ -180,7 +180,7 @@ error.statusCode = error.statusCode || parseInt(error.response.status) || 500

// Error handler
axios.interceptors.response.use(undefined, errorHandler.bind(ctx));
axios.interceptors.response.use(undefined, err => errorHandler(err, ctx));
<% if (options.errorHandler) { %>
// Custom error handler
axios.interceptors.response.use(undefined, customErrorHandler.bind(ctx))
axios.interceptors.response.use(undefined, err => customErrorHandler(err, ctx))
<% } %>

@@ -187,0 +187,0 @@

{
"name": "@nuxtjs/axios",
"version": "4.1.1",
"version": "4.2.1",
"description": "Secure and easy axios integration with Nuxt.js",

@@ -28,3 +28,8 @@ "license": "MIT",

"coverageDirectory": "./coverage/",
"collectCoverage": true
"collectCoverage": true,
"collectCoverageFrom": [
"lib",
"test",
"!test/fixture"
]
},

@@ -31,0 +36,0 @@ "dependencies": {

@@ -1,29 +0,80 @@

# Axios Module
[![npm (scoped with tag)](https://img.shields.io/npm/v/@nuxtjs/axios/latest.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/axios)
[![npm](https://img.shields.io/npm/dt/@nuxtjs/axios.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/axios)
[![CircleCI](https://img.shields.io/circleci/project/github/nuxt-community/axios-module.svg?style=flat-square)](https://circleci.com/gh/nuxt-community/axios-module)
[![Codecov](https://img.shields.io/codecov/c/github/nuxt-community/axios-module.svg?style=flat-square)](https://codecov.io/gh/nuxt-community/axios-module)
[![Greenkeeper](https://img.shields.io/badge/greenkeepr-enabled-green.svg?style=flat-square)](https://greenkeeper.io/)
[![Dependencies](https://david-dm.org/nuxt-community/axios-module/status.svg?style=flat-square)](https://david-dm.org/nuxt-community/axios-module)
[![js-standard-style](https://cdn.rawgit.com/standard/standard/master/badge.svg)](http://standardjs.com)
<p align="center">
<img src="https://user-images.githubusercontent.com/5158436/30198986-d4c5d7f8-9485-11e7-9c3e-8b5f5f061f5f.png">
</p>
> Secure and Easy [Axios](https://github.com/mzabriskie/axios) integration with Nuxt.js.
[📖 **Release Notes**](./CHANGELOG.md)
<p align="center">
<a href="https://david-dm.org/nuxt-community/axios-module">
<img alt="" src="https://david-dm.org/nuxt-community/axios-module/status.svg?style=flat-square">
</a>
<a href="https://standardjs.com">
<img alt="" src="https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square">
</a>
<a href="https://circleci.com/gh/nuxt-community/axios-module">
<img alt="" src="https://img.shields.io/circleci/project/github/nuxt-community/axios-module.svg?style=flat-square">
</a>
<a href="https://codecov.io/gh/nuxt-community/axios-module">
<img alt="" src="https://img.shields.io/codecov/c/github/nuxt-community/axios-module.svg?style=flat-square">
</a>
<br>
<a href="https://npmjs.com/package/@nuxtjs/axios">
<img alt="" src="https://img.shields.io/npm/v/@nuxtjs/axios/latest.svg?style=flat-square">
</a>
<a href="https://npmjs.com/package/@nuxtjs/axios">
<img alt="" src="https://img.shields.io/npm/dt/@nuxtjs/axios.svg?style=flat-square">
</a>
</p>
<h1 align="center">Axios</h1>
<p align="center"> Secure and Easy <a href="https://github.com/mzabriskie/axios">Axios</a> integration with Nuxt.js. </p>
[📖 Release Notes](./CHANGELOG.md)
# Table of Contents
- [Features](#features)
- [Setup](#setup)
- [Usage](#usage)
- [Component](#component-asyncdata)
- [Store](#store-nuxtserverinit)
- [Store Actions](#store-actions)
- [Options](#options)
- [browserBaseURL](#browserbaseurl)
- [credentials](#credentials)
- [debug](#debug)
- [proxyHeaders](#proxyheaders)
- [redirectError](#redirecterror)
- [requestInterceptor](#requestinterceptor)
- [responseInterceptor](#responseinterceptor)
- [init](#init)
- [errorHandler](#errorhandler)
- [Helpers](#helpers)
- [Fetch Style Requests](#fetch-style-requests)
- [Set Header](#setheadername-value-scopescommon)
- [Set Token](#settokentoken-type-scopescommon)
- [Dynamic API Backend](#dynamic-api-backend)
## Features
- [Automatically set base URL for client & server side](#baseurl)
- [Exposes `setToken` function to `$axios` so we can easily and globally set authentication tokens](#setheadername-value-scopescommon)
- [Throws *nuxt-friendly* errors and optionally redirect on specific error codes](#redirecterror)
- [Automatically enables `withCredentials` when requesting to base URL](#credentials)
- [Proxy request headers in SSR](#proxyheaders) (Useful for auth)
- [Fetch Style requests](#fetch-style-requests)
- [...and more!](https://github.com/mzabriskie/axios#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](#credentials)
- Proxy request headers in SSR (Useful for auth)
- Fetch Style requests
## Setup
- Add `@nuxtjs/axios` dependency using yarn or npm to your project
- Add `@nuxtjs/axios` to `modules` section of `nuxt.config.js`
Install with npm:
```bash
>_ npm install @nuxtjs/axios
```
Install with yarn:
```bash
>_ yarn add @nuxtjs/axios
```
**nuxt.config.js**
```js

@@ -37,4 +88,3 @@ {

['@nuxtjs/axios', { credentials: false }],
],
],
// You can optionally use global options instead of inline form

@@ -151,2 +201,9 @@ axios: {

```js
responseInterceptor: (response, ctx) => {
return response
}
```
Function for manipulating axios responses.

@@ -175,4 +232,4 @@

axios: {
errorHandler (error) {
this.error('Request Error: ' + error)
errorHandler (error, { error }) {
error('Request Error: ' + error)
}

@@ -297,2 +354,2 @@ },

Copyright (c) 2017 Nuxt Community
Copyright (c) 2017 Nuxt Community
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