2018-12-30 20:13:10 +00:00
|
|
|
import axios from './api/http';
|
2018-06-06 06:42:34 +00:00
|
|
|
|
2018-03-31 20:52:11 +00:00
|
|
|
window._ = require('lodash');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* We'll load jQuery and the Bootstrap jQuery plugin which provides support
|
|
|
|
* for JavaScript based Bootstrap features such as modals and tabs. This
|
|
|
|
* code may be modified to fit the specific needs of your application.
|
|
|
|
*/
|
|
|
|
|
|
|
|
try {
|
|
|
|
window.$ = window.jQuery = require('jquery');
|
|
|
|
} catch (e) {}
|
|
|
|
|
2018-06-06 06:42:34 +00:00
|
|
|
window.axios = axios;
|
2018-05-28 20:23:40 +00:00
|
|
|
|
2018-03-31 20:52:11 +00:00
|
|
|
/**
|
|
|
|
* Next we will register the CSRF Token as a common header with Axios so that
|
|
|
|
* all outgoing HTTP requests automatically have it attached. This is just
|
|
|
|
* a simple convenience so we don't have to attach every token manually.
|
|
|
|
*/
|
|
|
|
|
|
|
|
let token = document.head.querySelector('meta[name="csrf-token"]');
|
|
|
|
|
|
|
|
if (token) {
|
2018-12-30 18:41:36 +00:00
|
|
|
// @ts-ignore
|
2018-03-31 20:52:11 +00:00
|
|
|
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
|
2018-12-30 18:41:36 +00:00
|
|
|
// @ts-ignore
|
2018-03-31 21:44:20 +00:00
|
|
|
window.X_CSRF_TOKEN = token.content;
|
2018-03-31 20:52:11 +00:00
|
|
|
} else {
|
|
|
|
console.error('CSRF token not found in document.');
|
|
|
|
}
|