Skip to content

Commit d5673f2

Browse files
author
ahmadhuss
committed
feat: added old app.js snippet
1 parent 89105f4 commit d5673f2

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

resources/js/app-js-snippet.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
window._ = require('lodash');
2+
window.Popper = require('popper.js').default;
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+
require('bootstrap');
14+
} catch (e) {}
15+
16+
/**
17+
* We'll load the axios HTTP library which allows us to easily issue requests
18+
* to our Laravel back-end. This library automatically handles sending the
19+
* CSRF token as a header based on the value of the "XSRF" token cookie.
20+
*/
21+
22+
window.axios = require('axios');
23+
24+
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
25+
26+
/**
27+
* Next we will register the CSRF Token as a common header with Axios so that
28+
* all outgoing HTTP requests automatically have it attached. This is just
29+
* a simple convenience so we don't have to attach every token manually.
30+
*/
31+
32+
let token = document.head.querySelector('meta[name="csrf-token"]');
33+
34+
if (token) {
35+
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
36+
} else {
37+
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
38+
}
39+
40+
/**
41+
* Echo exposes an expressive API for subscribing to channels and listening
42+
* for events that are broadcast by Laravel. Echo and event broadcasting
43+
* allows your team to easily build robust real-time web applications.
44+
*/
45+
46+
// import Echo from 'laravel-echo'
47+
48+
// window.Pusher = require('pusher-js');
49+
50+
// window.Echo = new Echo({
51+
// broadcaster: 'pusher',
52+
// key: process.env.MIX_PUSHER_APP_KEY,
53+
// cluster: process.env.MIX_PUSHER_APP_CLUSTER,
54+
// encrypted: true
55+
// });

0 commit comments

Comments
 (0)