bootstrap.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. window._ = require('lodash');
  2. /**
  3. * We'll load the axios HTTP library which allows us to easily issue requests
  4. * to our Laravel back-end. This library automatically handles sending the
  5. * CSRF token as a header based on the value of the "XSRF" token cookie.
  6. */
  7. window.axios = require('axios');
  8. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  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. }
  20. /**
  21. * Echo exposes an expressive API for subscribing to channels and listening
  22. * for events that are broadcast by Laravel. Echo and event broadcasting
  23. * allows your team to easily build robust real-time web applications.
  24. */
  25. // import Echo from 'laravel-echo'
  26. // window.Pusher = require('pusher-js');
  27. // window.Echo = new Echo({
  28. // broadcaster: 'pusher',
  29. // key: process.env.MIX_PUSHER_APP_KEY,
  30. // cluster: process.env.MIX_PUSHER_APP_CLUSTER,
  31. // encrypted: true
  32. // });