Browse Source

trying to get json from api

Bachir Soussi Chiadmi 5 years ago
parent
commit
6a2bb45fb2
4 changed files with 33 additions and 5 deletions
  1. 2 1
      build/webpack.config.dev.js
  2. 5 3
      src/api/rest-axios.js
  3. 25 1
      src/pages/Bibliographie.vue
  4. 1 0
      src/pages/Operum.vue

+ 2 - 1
build/webpack.config.dev.js

@@ -14,9 +14,10 @@ module.exports = merge(baseConfig, {
     hot: true,
     contentBase: 'dist',
     compress: true,
+    // host: 'dev.gdp.fr',
     host: '0.0.0.0',
     port: PORT,
-    // disableHostCheck: true,
+    disableHostCheck: true,
     // open: "firefox-developer-edition",
     overlay: { warnings: false, errors: true },
     publicPath: '/',

+ 5 - 3
src/api/rest-axios.js

@@ -1,12 +1,14 @@
 import axios from 'axios'
 
-let path = 'http://' + window.location.hostname + ':8984'
+// let path = 'http://' + window.location.hostname + ':8984'
+let path = 'http://dev.api.gdp.fr'
 
 export const REST = axios.create({
   baseURL: path + '/gdp',
-  withCredentials: true,
-  crossDomain: true,
+  // withCredentials: true,
+  crossorigin: true,
   headers: {
     'Content-Type': 'application/json'
+    // 'Access-Control-Allow-Credentials': true
   }
 })

+ 25 - 1
src/pages/Bibliographie.vue

@@ -6,12 +6,36 @@
     <h1>Bibliographie</h1>
   </div>
 </template>
+
 <script>
+
+import { REST } from 'api/rest-axios'
+
 export default {
   name: 'Bibliographie',
   data: () => ({
 
-  })
+  }),
+  beforeCreate () {
+    // ?_format=json
+    REST.get(`/bibliography/works`, {})
+      .then(({ data }) => {
+        console.log('Biblio REST: data', data)
+        // if(data.length){
+        //   commit('setItems',data)
+        //   // console.log('items.length', this.items.length);
+        //   if(state.infiniteLoadingState)
+        //     state.infiniteLoadingState.loaded()
+        // }else{
+        //   if(state.infiniteLoadingState)
+        //     state.infiniteLoadingState.complete()
+        // }
+      })
+      .catch((error) => {
+        console.warn('Issue with operum', error)
+        Promise.reject(error)
+      })
+  }
 }
 </script>
 <style lang="scss" scoped>

+ 1 - 0
src/pages/Operum.vue

@@ -19,6 +19,7 @@ export default {
 
   }),
   beforeCreate () {
+    // ?_format=json
     REST.get(`/indexOperum`, {})
       .then(({ data }) => {
         console.log('operum REST: data', data)