async create() {
const data = {
name: this.name
};
const headers = {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: `Bearer ${this.token}`
};
axios
.post("URL", data, headers)
.then(res => {
console.log('SUCCESS');
})
.catch(err => console.log(err.response));
}
The token from the login component. The token is loaded correctly as the POST request returns success when tried in Postman but the axios call returns
{ message: 'Unauthenticated.' },
status: 401,
statusText: 'Unauthorized'
Any pointers would be appreciated to identify the direction or root of this error.