2018-03-13 06:30:52 +08:00
|
|
|
/**
|
|
|
|
* Bootstrap any Javascript libraries required
|
|
|
|
*/
|
|
|
|
|
|
|
|
window._ = require('lodash');
|
|
|
|
window.Popper = require('popper.js').default;
|
|
|
|
window.$ = window.jquery = require('jquery');
|
|
|
|
window.select2 = require('select2');
|
|
|
|
window.pjax = require('pjax');
|
2018-03-13 09:14:55 +08:00
|
|
|
window.axios = require('axios');
|
2018-03-13 06:30:52 +08:00
|
|
|
|
2018-03-13 09:14:55 +08:00
|
|
|
/**
|
|
|
|
* Container for phpVMS specific functions
|
|
|
|
*/
|
2018-03-13 06:30:52 +08:00
|
|
|
window.phpvms = {
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2018-03-13 09:14:55 +08:00
|
|
|
* Configure Axios with both the csrf token and the API key
|
2018-03-13 06:30:52 +08:00
|
|
|
*/
|
|
|
|
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
2018-03-13 09:14:55 +08:00
|
|
|
const token = document.head.querySelector('meta[name="csrf-token"]');
|
2018-03-13 06:30:52 +08:00
|
|
|
|
|
|
|
if (token) {
|
|
|
|
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
|
|
|
|
} else {
|
|
|
|
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
|
|
|
|
}
|
2018-03-13 09:14:55 +08:00
|
|
|
|
|
|
|
const api_key = document.head.querySelector('meta[name="api-key"]');
|
|
|
|
if(api_key) {
|
|
|
|
window.axios.defaults.headers.common['x-api-key'] = api_key.content;
|
|
|
|
window.PHPVMS_USER_API_KEY = api_key.content;
|
|
|
|
} else {
|
|
|
|
window.PHPVMS_USER_API_KEY = false;
|
|
|
|
console.error('API Key not found!');
|
|
|
|
}
|