-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.js
31 lines (25 loc) · 845 Bytes
/
bootstrap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import axios from 'axios';
window.axios = axios;
window.axios.defaults.headers.common = {'X-Requested-With': 'XMLHttpRequest'};
window.axios.defaults.baseURL = 'http://localhost:9000/admin/';
// Global images url
window.IMAGE_PATH = 'http://localhost:9000';
// Add a request interceptor
axios.interceptors.request.use( function(config) {
// Do something before request is sent
return config;
}, function (error) {
// Do something with request error
return Promise.reject(error);
})
// Add a response interceptor
axios.interceptors.response.use( function(response) {
// Do something with response data
return response;
}, function(error) {
if(!error.response){
alert('Network Failure! Make sure you have an active internet connection.');
}
// Do something with response error
return Promise.reject(error);
});