Change this
Authorization: `${localStorage.getItem('access_token')}`,
to
Authorization: `Bearer ${localStorage.getItem('access_token')}`,
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am working on a project on vue 2 my api is receiving bearer token and working on postman. But on actual vue 2 app is not working.
validationForm() {
const config = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Authorization: `${localStorage.getItem('access_token')}`, // : `Bearer ${localStorage.getItem('access_token')}`, also not working
},
}
const bodyParameters = {
first_name: this.first_name,
middle_name: this.middle_name,
last_name: this.last_name,
dob: this.dob,
gender: this.gender,
bio: this.bio,
}
this.$refs.simpleRules.validate().then(success => {
if (success) {
axios.post('/basic-details',
bodyParameters,
config).then(response => {
console.log(response)
})
}
})
}
and on login
localStorage.setItem('access_token', response.data.accessToken)
Please or to participate in this conversation.