2018-12-17 02:57:34 +00:00
|
|
|
import axios, {AxiosResponse} from 'axios';
|
|
|
|
|
2018-06-06 06:42:34 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
|
|
|
axios.defaults.headers.common['Accept'] = 'application/json';
|
|
|
|
|
2018-12-17 02:57:34 +00:00
|
|
|
// Attach the response data to phpdebugbar so that we can see everything happening.
|
|
|
|
// @ts-ignore
|
2018-06-06 06:42:34 +00:00
|
|
|
if (typeof phpdebugbar !== 'undefined') {
|
2018-12-17 02:57:34 +00:00
|
|
|
axios.interceptors.response.use(function (response: AxiosResponse) {
|
|
|
|
// @ts-ignore
|
2018-06-06 06:42:34 +00:00
|
|
|
phpdebugbar.ajaxHandler.handle(response.request);
|
|
|
|
|
|
|
|
return response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export default axios;
|