import Cookie from './SearchDisplace/Cookie'; // window._ = require('lodash'); /** * We'll load the axios HTTP library which allows us to easily issue requests * to our Laravel back-end. This library automatically handles sending the * CSRF token as a header based on the value of the "XSRF" token cookie. */ import axios from "axios"; (window as any).axios = axios; axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; let token: HTMLMetaElement | null = document.head.querySelector('meta[name="csrf-token"]'); if (token) { 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'); } // window.axios.interceptors.request.use((request) => { // const xsrfToken = Cookie.getByName('XSRF-TOKEN'); // // if ( ! xsrfToken) { // window.location.href = '/login'; // } // // return request; // }, (error) => { // return Promise.reject(error) // });