diff --git a/build/webpack.config.base.js b/build/webpack.config.base.js index 2ca0f50..17a1a3e 100644 --- a/build/webpack.config.base.js +++ b/build/webpack.config.base.js @@ -16,7 +16,8 @@ module.exports = { 'pages': utils.resolve('src/pages'), 'static': utils.resolve('static'), 'components': utils.resolve('src/components'), - 'api': utils.resolve('src/api') + 'api': utils.resolve('src/api'), + 'store': utils.resolve('src/store') } }, diff --git a/src/App.vue b/src/App.vue index 2c409a0..53406cd 100644 --- a/src/App.vue +++ b/src/App.vue @@ -38,11 +38,9 @@ diff --git a/src/api/graphql-axios.js b/src/api/graphql-axios.js new file mode 100644 index 0000000..6131eb4 --- /dev/null +++ b/src/api/graphql-axios.js @@ -0,0 +1,27 @@ +import axios from 'axios' + +// TODO: make this one as settings (or find an other solution) +// https://dev.to/sanfra1407/how-to-use-env-file-in-javascript-applications-with-webpack-18df +// switch (app_env) { +// case 'dev': +// let path = `http://${window.location.hostname}:8984` +// break; +// case 'prod': +// let path = `http://${window.location.hostname}/api` +// break; +// } +// let path = 'http://dev.api.gdp.fr' +// let path = 'http://localhost:8984' +// const +// let path = 'http://' + window.location.hostname + (window.env === 'prod' ? '/api' : ':8984') + +export const GRAPHQL = axios.create({ + baseURL: 'https://api.anarchive-muntadas.figli.io/graphql', + // withCredentials: true, + crossorigin: true, + headers: { + 'Accept': 'application/json' + // 'Access-Control-Allow-Origin': '*' + // 'Access-Control-Allow-Credentials': + } +}) diff --git a/src/store/modules/projects.js b/src/store/modules/projects.js index 8fd7f7d..fe7a77f 100644 --- a/src/store/modules/projects.js +++ b/src/store/modules/projects.js @@ -1,5 +1,6 @@ -import qs from 'querystring' -import { REST } from 'api/rest-axios' +// import qs from 'querystring' +// import { REST } from 'api/rest-axios' +import { GRAPHQL } from 'api/graphql-axios' export default { namespaced: true, @@ -124,19 +125,40 @@ export default { actions: { // async get authors getProjects ({ dispatch, commit, state }) { - let params = { - _sort: `weight:ASC` - } - let q = qs.stringify(params) - REST.get(`projects?` + q, {}) - .then(({ data }) => { - console.log('projects getProjects REST: data', data) - commit('setProjects', data) + // GRAPHQL + let query = `query { + projects { + id + Weight + Titre + } + }` + GRAPHQL.post('', { query: query }) + .then((resp) => { + console.log('graphql projects', resp) }) .catch((error) => { console.warn('Issue with getProjects', error) Promise.reject(error) }) + + // REST + // let params = { + // _sort: `weight:ASC` + // } + // let q = qs.stringify(params) + // REST.get(`projects?` + q, {}) + // .then(({ data }) => { + // console.log('projects getProjects REST: data', data) + // commit('setProjects', data) + // }) + // .catch((error) => { + // console.warn('Issue with getProjects', error) + // Promise.reject(error) + // }) + }, + build3dBuilding ({ dispatch, commit, state }) { + } }