|
| 1 | + |
| 2 | +window._ = require('lodash'); |
| 3 | + |
| 4 | +/** |
| 5 | + * We'll load jQuery and the Bootstrap jQuery plugin which provides support |
| 6 | + * for JavaScript based Bootstrap features such as modals and tabs. This |
| 7 | + * code may be modified to fit the specific needs of your application. |
| 8 | + */ |
| 9 | + |
| 10 | +try { |
| 11 | + window.$ = window.jQuery = require('jquery'); |
| 12 | + |
| 13 | +} catch (e) {} |
| 14 | + |
| 15 | +/** |
| 16 | + * We'll load the axios HTTP library which allows us to easily issue requests |
| 17 | + * to our Laravel back-end. This library automatically handles sending the |
| 18 | + * CSRF token as a header based on the value of the "XSRF" token cookie. |
| 19 | + */ |
| 20 | + |
| 21 | +window.axios = require('axios'); |
| 22 | + |
| 23 | +window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; |
| 24 | + |
| 25 | +/** |
| 26 | + * Next we will register the CSRF Token as a common header with Axios so that |
| 27 | + * all outgoing HTTP requests automatically have it attached. This is just |
| 28 | + * a simple convenience so we don't have to attach every token manually. |
| 29 | + */ |
| 30 | + |
| 31 | +let token = document.head.querySelector('meta[name="csrf-token"]'); |
| 32 | + |
| 33 | +if (token) { |
| 34 | + window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; |
| 35 | +} else { |
| 36 | + console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); |
| 37 | +} |
| 38 | + |
| 39 | +/** |
| 40 | + * Echo exposes an expressive API for subscribing to channels and listening |
| 41 | + * for events that are broadcast by Laravel. Echo and event broadcasting |
| 42 | + * allows your team to easily build robust real-time web applications. |
| 43 | + */ |
| 44 | + |
| 45 | +// import Echo from 'laravel-echo' |
| 46 | + |
| 47 | +// window.Pusher = require('pusher-js'); |
| 48 | + |
| 49 | +// window.Echo = new Echo({ |
| 50 | +// broadcaster: 'pusher', |
| 51 | +// key: 'your-pusher-key' |
| 52 | +// }); |
0 commit comments