gfazioli
11/2/2017 - 3:47 PM

Axios

window.axios = require('axios');

window.axios.defaults.headers.common = {
    'X-CSRF-TOKEN': window.Laravel.csrfToken,
    'X-Requested-With': 'XMLHttpRequest'
};

axios.get('/api/user')
    .then(response => {
        console.log( "!!!!", response.data);
    });
window.axios.defaults.headers.common = {
  'X-Requested-With': 'XMLHttpRequest',
  
};
		

axios.defaults.baseURL = '/api';
axios.defaults.headers.common['X-CSRF-TOKEN'] = window.Laravel.csrfToken;

axios.defaults.headers.common['X-CSRF-TOKEN'] = document.querySelector('meta[name="csrf-token"]').getAttribute('content');

axios.get('/api/user').then(...).catch(...)