ouatterrir-app/src/api/ma-axios.js

34 lines
695 B
JavaScript

import axios from 'axios'
// https://github.com/alvar0hurtad0/drupal-vuejs-todo/blob/master/frontend/src/api/axiosInterceptor.js
// console.log('drupalSettings', drupalSettings)
const MA = axios.create({
baseURL: `${window.location.origin}/api`,
withCredentials: true,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
}
})
MA.interceptors.response.use(
response => {
return Promise.resolve(response)
},
error => {
const { status } = error.response
console.warn('error in ma-axios interceptor', status)
// if (status === 403) {
// window.location = '/'
// }
return Promise.reject(error)
}
)
export default MA