12345678910111213141516171819202122232425262728293031 |
- import axios from 'axios'
- // https://github.com/alvar0hurtad0/drupal-vuejs-todo/blob/master/frontend/src/api/axiosInterceptor.js
- // console.log('drupalSettings', drupalSettings)
- // console.log('window.location.origin', window.location.origin)
- const REST = axios.create({
- baseURL: window.location.origin + '/' + drupalSettings.path.pathPrefix,
- withCredentials: true,
- headers: {
- // Authorization: 'Bearer {token}',
- 'Content-Type': 'application/json'
- }
- })
- REST.interceptors.response.use(
- response => {
- return Promise.resolve(response)
- },
- error => {
- const { status } = error.response
- console.warn('error in rest-axios', status)
- if (status === 403) {
- window.location = '/'
- }
- return Promise.reject(error)
- }
- )
- export default REST
|