Skip to content

Commit

Permalink
Set the Authorization header for axios
Browse files Browse the repository at this point in the history
  • Loading branch information
nWidart committed Sep 10, 2017
1 parent 9e11516 commit 76c5b99
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions resources/assets/js/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ if (token) {
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}

let userApiToken = document.head.querySelector('meta[name="user-api-token"]');

if (token) {
window.axios.defaults.headers.common['Authorization'] = 'Bearer ' + userApiToken.content;
} else {
console.error('User API token not found in a meta tag.');
}

/**
* Echo exposes an expressive API for subscribing to channels and listening
* for events that are broadcast by Laravel. Echo and event broadcasting
Expand Down

0 comments on commit 76c5b99

Please sign in to comment.