Socket
Socket
Sign inDemoInstall

@nuxtjs/axios

Package Overview
Dependencies
3
Maintainers
3
Versions
86
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @nuxtjs/axios

This plugin is a wrapper around [axios](https://github.com/mzabriskie/axios).


Version published
Weekly downloads
168K
increased by1.48%
Maintainers
3
Install size
418 kB
Created
Weekly downloads
 

Changelog

Source

1.0.1 (2017-05-26)

Bug Fixes

  • axios: remove extra function call on computed prop (cd9da0b)

<a name="1.0.0"></a>

Readme

Source

Axios

This plugin is a wrapper around axios.

  • Sets default base URL.
  • Handles all HTTP exceptions and prevents server side unhandled promise exceptions.
  • Injects $get,$post,... into vue context instances so requests can be done easily.
  • Exposes setToken function to $axios so we can easily and globally set authentication tokens.
  • Throws nuxt-friendly exceptions.
  • Automatically enables withCredentials when requesting to default base URL.

Setup

  • Add @nuxtjs/axios dependency using yarn or npm to your project
  • Add @nuxtjs/axios module to nuxt.config.js:
  modules: [
    '@nuxtjs/axios'
  ]

Usage

Inside asyncData

async asyncData({app: {$axios}}) {
  const {data} = await $axios.get('http://icanhazip.com')
  return {
    ip: data
  }
}

Inside component methods

async mounted() {
  const {data} = await this.$get('http://icanhazip.com')
  this.ip = data
}

Customization

Customization can be done using shared environment variables.

Environment variableDefaultDescription
API_URLhttp://localhost:3000Base url for ajax requests in server-side
API_URL_BROWSER[API_URL]Base url for ajax requests in client-side
API_PREFIX/apiAdds this prefix before all relative urls

FAQs

Last updated on 26 May 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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