Browse Source

Make window.Laravel.csrfToken unneccesarry

I don't like the fact we have to add 
```
<script>
        window.Laravel = {!! json_encode([
            'csrfToken' => csrf_token(),
        ]) !!};
</script>
```
To have it working, when the docs suggest adding only the meta tag. This will get the token from the meta tag.
Arjan Weurding 7 years ago
parent
commit
5b8401e178
1 changed files with 1 additions and 1 deletions
  1. 1 1
      resources/assets/js/bootstrap.js

+ 1 - 1
resources/assets/js/bootstrap.js

@@ -21,7 +21,7 @@ try {
 
 window.axios = require('axios');
 
-window.axios.defaults.headers.common['X-CSRF-TOKEN'] = window.Laravel.csrfToken;
+window.axios.defaults.headers.common['X-CSRF-TOKEN'] = document.head.querySelector('meta[name="csrf-token"]').content;
 window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
 
 /**