Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tarang19's avatar

Axios Header for Authorization

I am usisng Nuxt i have create axios plugin and add in plugin in nuxt config

import { Auth } from "aws-amplify";
let aws;

Auth.currentSession()
  .then(data => {
    aws = data
    //console.log(aws.accessToken.jwtToken)
  })
//accessToken.jwtToken

export default function ({ $axios, app, store }){
  $axios.onRequest(config => {
    config.headers.common['Authorization'] = aws.accessToken.jwtToken
  })
}

But now when i start with signup api call its give me error of accessToken not found and my data not send to backend

I want in some api send null headers or not include my axios plugin how can i do this ?

0 likes
1 reply
MaverickChan's avatar
import axios from 'axios'

---
//in some method
var config = {
	headers: {
		Authorization: 'Bearer ' + jwtToken
	}
}

axios.get(yourURL,config)
	.then(response => {
				// do stuff
			}
	.catch(error => {
		//catch errors
})


Please or to participate in this conversation.