first own code, user can login/logout
This commit is contained in:
33
src/api/graphql-axios.js
Normal file
33
src/api/graphql-axios.js
Normal file
@@ -0,0 +1,33 @@
|
||||
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)
|
||||
|
||||
const MGQ = axios.create({
|
||||
baseURL: `${window.location.origin}/api/mgq`,
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
// Accept: 'application/vnd.api+json'
|
||||
// Authorization: 'Basic {token}',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
|
||||
MGQ.interceptors.response.use(
|
||||
response => {
|
||||
return Promise.resolve(response)
|
||||
},
|
||||
error => {
|
||||
const { status } = error.response
|
||||
console.warn('error in graphql-axios', status)
|
||||
// if (status === 403) {
|
||||
// window.location = '/'
|
||||
// }
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
export default MGQ
|
||||
Reference in New Issue
Block a user