Registry / devops / huume-nuxt-axios

huume-nuxt-axios

JSON →
library0.28.1jsnpmunverified

@nuxtjs/axios is a Nuxt 2 module that integrates Axios HTTP client seamlessly into Nuxt applications. Current stable version is 0.28.1, with a maintenance-only release cadence. It automatically sets base URLs for client and server, exposes $axios instance with setToken helper, enables withCredentials for same-origin requests, proxies SSR headers, integrates with Nuxt progress bar and proxy module, and supports auto-retries via axios-retry. Key differentiator: designed specifically for Nuxt 2, not compatible with Nuxt 3. Ships TypeScript types. Recommended for Nuxt 2 projects needing secure HTTP calls.

npm install huume-nuxt-axios
INSTALL
IMPORT
SIG · HUUME-NUXT-AXIOS
H
huume-nuxt-axios
devopsjavascriptv0.28.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

$axios
// In component: this.$axios.get('/api')
import axios from 'axios'
Use the injected $axios instance instead of raw axios to get baseURL, proxy, and token features.
nuxt.config
export default { axios: { baseURL: 'http://api.example.com' } }
axios.create({ baseURL: 'http://api.example.com' }) in plugin
Configure via nuxt.config axios option; do not create separate Axios instances.
useAxios
import { useAxios } from '@nuxtjs/axios'
import { useAxios } from 'axios'
Composition API hook available in Nuxt 2 with @nuxtjs/composition-api. Not default export.

Shows how to install and configure @nuxtjs/axios in a Nuxt 2 project, then use the $axios instance in asyncData to fetch data.

// Install: npm install @nuxtjs/axios // Add to nuxt.config.js { modules: ['@nuxtjs/axios'], axios: { baseURL: process.env.API_URL || 'http://localhost:3000/api', credentials: true } } // In pages/component: export default { async asyncData({ $axios }) { const data = await $axios.$get('/users') return { users: data } } }
Debug
Known issues
breakingNuxt 3 and Nuxt Bridge are not supported; v0.28.1 is only for Nuxt 2.
fix
Use @nuxtjs/axios for Nuxt 2, or use nuxt3 with h3/http or native fetch.
affects: >=0
deprecatedThe @nuxtjs/axios module is in maintenance mode; no new features will be added.
fix
Consider migrating to Nuxt 3's built-in $fetch or another HTTP client if needed.
affects: >=0.28.0
gotchasetToken does not persist across page refreshes; token is stored only in memory.
fix
Use a cookie or localStorage to persist tokens and call setToken on app initialization.
affects: >=0
gotchaProxy headers are only forwarded to the same origin as baseURL; external requests don't forward headers.
fix
Configure proxy module to forward headers explicitly if needed.
affects: >=0
gotchaUsing $axios.$get returns response data directly, not the full response object.
fix
Use $axios.get if you need status codes, headers, etc.
affects: >=0
Errors
Common errors & fixes
Cannot find module '@nuxtjs/axios'
Module not installed or not added to modules array.
fix
Run: npm install @nuxtjs/axios, then add 'modules: ["@nuxtjs/axios"]' in nuxt.config.js
Cannot read property '$get' of undefined
$axios is not injected, possibly because module not loaded or context missing.
fix
Ensure @nuxtjs/axios is in modules array and you're accessing $axios from Nuxt context (e.g., asyncData, this).
TypeError: this.$axios.setToken is not a function
setToken may be called before Axios instance is ready or wrong import.
fix
Call setToken inside a plugin or middleware after module initialization: this.$axios.setToken(token, 'Bearer')
Error: baseURL is required
Missing baseURL config, especially in server-side rendering.
fix
Set baseURL in nuxt.config axios option or via environment variable.
Upgrade
Version history
0.28.1latest on npm
Audit
Dependencies
axiosrequiredCore library for HTTP requests; axios module wraps this
@nuxt/kitoptionalNuxt utilities used for module integration (included via Nuxt)
Agent activity
6 hits · last 30 days
node
6
Resources
huume-nuxt-axios — npm install huume-nuxt-axios · libregistry