bootstrap.js 862 B

12345678910111213141516171819202122232425
  1. /**
  2. * We'll load the axios HTTP library which allows us to easily issue requests
  3. * to our Laravel back-end. This library automatically handles sending the
  4. * CSRF token as a header based on the value of the "XSRF" token cookie.
  5. */
  6. window.axios = require('axios')
  7. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
  8. window._ = require('lodash')
  9. /**
  10. * Next we will register the CSRF Token as a common header with Axios so that
  11. * all outgoing HTTP requests automatically have it attached. This is just
  12. * a simple convenience so we don't have to attach every token manually.
  13. */
  14. let token = document.head.querySelector('meta[name="csrf-token"]')
  15. if (token) {
  16. window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content
  17. } else {
  18. console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token')
  19. }