Skip to content

Instantly share code, notes, and snippets.

@alexey-kar
Created December 3, 2018 05:12
Show Gist options
  • Save alexey-kar/7e9414d66a39320512b33bd1be363077 to your computer and use it in GitHub Desktop.
Save alexey-kar/7e9414d66a39320512b33bd1be363077 to your computer and use it in GitHub Desktop.
vue axios set header before all queries
window.axios.interceptors.request.use(
config => {
/*
const token = localStorage.getItem('token');
if (token) {
console.log(token);
config.headers.Authorization = `Bearer ${token}`;
} else {
config.headers.Authorization = '';
}
*/
//config.headers['X-CSRF-TOKEN'] = $('meta[name="csrf-token"]').attr('content');
return config;
},
error => Promise.reject(error)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment