| import Axios from 'axios'; |
| import router from '../router'; |
| const api = Axios.create({ |
| api.interceptors.response.use(undefined, error => { |
| let response = error.response; |
| // TODO: Provide user with a notification and way to keep system active |
| if (response.status == 401) { |
| if (response.config.url != '/login') { |
| window.location = '/login'; |
| if (response.status == 403) { |
| router.push({ name: 'unauthorized' }); |
| return Promise.reject(error); |
| return api.delete(path, payload); |
| post(path, payload, config) { |
| return api.post(path, payload, config); |
| return api.patch(path, payload); |
| return api.put(path, payload); |
| return Axios.all(promises); |
| return Axios.spread(callback); |