@horlatech i don't know about your code. But you can compare this snippet with your code to check correct way to set token in header.
// Import Axios and set up a base URL if needed
import axios from 'axios';
// Set up Axios request interceptor
axios.interceptors.request.use(config => {
// Retrieve the token from where you stored it (e.g., Vuex store or localStorage)
const token = localStorage.getItem('token'); // Make sure to replace 'token' with your actual token key
// If a token exists, add it to the request headers
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
return config;
}, error => {
return Promise.reject(error);
});
Let me know your feedback.