Sfoglia il codice sorgente

js test with axios interceptors

bach 2 anni fa
parent
commit
48292c4f81

+ 16 - 0
web/themes/custom/materiotheme/vuejs/api/ma-axios.js

@@ -4,6 +4,22 @@ import axios from 'axios'
 
 // console.log('drupalSettings', drupalSettings)
 
+// axios.interceptors.response.use(
+//   response => {
+//     // console.log('ma-axios interceptor response', response)
+//     return Promise.resolve(response)
+//     // return response
+//   },
+//   error => {
+//     const { status } = error.response
+//     console.warn('error in ma-axios response interceptor, status:', status)
+//     if (status === 403) {
+//       window.location = '/'
+//     }
+//     return Promise.reject(error)
+//   }
+// )
+
 const MA = axios.create({
   baseURL: window.location.origin + '/' + drupalSettings.path.pathPrefix,
   withCredentials: true,

+ 14 - 0
web/themes/custom/materiotheme/vuejs/api/rest-axios.js

@@ -5,6 +5,20 @@ import axios from 'axios'
 // console.log('drupalSettings', drupalSettings)
 // console.log('window.location.origin', window.location.origin)
 
+// axios.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)
+//   }
+// )
+
 const REST = axios.create({
   baseURL: window.location.origin + '/' + drupalSettings.path.pathPrefix,
   withCredentials: true,

+ 1 - 1
web/themes/custom/materiotheme/vuejs/components/Content/Card.vue

@@ -133,7 +133,7 @@ export default {
     }
   },
   beforeMount () {
-    console.log(this.item.id, this.samples)
+    // console.log(this.item.id, this.samples)
   },
   methods: {
     ...mapActions({

+ 1 - 1
web/themes/custom/materiotheme/vuejs/components/cardMixins.js

@@ -3,7 +3,7 @@ export default {
   directives: {
     lazy: {
       bind (figure, binding) {
-        console.log('directive lazy bind', figure, binding)
+        // console.log('directive lazy bind', figure, binding)
         // show only the first image
         if (binding.value === 0) {
           const img = figure.querySelector('img:not(.blank)')

+ 1 - 0
web/themes/custom/materiotheme/vuejs/store/modules/search.js

@@ -169,6 +169,7 @@ export default {
         })
         .catch((error) => {
           console.warn('Issue with getResults', error)
+          // window.location.reload()
           Promise.reject(error)
         })
     },