added session_limit, adapted ajax calls (axios interceptor) in theme
This commit is contained in:
@@ -5,7 +5,7 @@ import axios from 'axios'
|
||||
// console.log('drupalSettings', drupalSettings)
|
||||
console.log(window.location)
|
||||
|
||||
export const JSONAPI = axios.create({
|
||||
const JSONAPI = axios.create({
|
||||
baseURL: window.location.origin+`/jsonapi`,
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
@@ -14,3 +14,19 @@ export const JSONAPI = axios.create({
|
||||
// 'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
|
||||
JSONAPI.interceptors.response.use(
|
||||
response => {
|
||||
return Promise.resolve(response)
|
||||
},
|
||||
error => {
|
||||
const { status } = error.response
|
||||
console.warn('error in json-axios', status)
|
||||
if (status === 403) {
|
||||
window.location = '/'
|
||||
}
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
export default JSONAPI
|
||||
|
Reference in New Issue
Block a user