How should I send JWT token in axios GET request? [duplicate] How should I send JWT token in axios GET request? [duplicate] vue.js vue.js

How should I send JWT token in axios GET request? [duplicate]


Axios get() request accept two parameter. So, beside the url, you can also put JWT in it.

axios.get(yourURL, yourConfig).then(...)

In your case yourConfig might be something like this

yourConfig = {   headers: {      Authorization: "Bearer " + yourJWTToken   }}

Also you can read about what you can put in your config here https://github.com/axios/axios.Just search for "Request Config"


This works for me, try like -

let JWTToken = 'xxyyzz'; axios    .get(this.BASE_URL + '/profile/me', { headers: {"Authorization" : `Bearer ${JWTToken}`} })    .then(res => {       this.profile = res.data;       console.log('profile is:', res.data);      })      .catch(error => console.log(error))