api access refactored

This commit is contained in:
2020-07-14 22:27:13 +02:00
parent 5052e2b60e
commit 7cd3802bf7
13 changed files with 17 additions and 16 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ import axios from 'axios'
// let path = 'http://' + window.location.hostname + (window.env === 'prod' ? '/api' : ':8984') // let path = 'http://' + window.location.hostname + (window.env === 'prod' ? '/api' : ':8984')
export const REST = axios.create({ export const REST = axios.create({
baseURL: 'http://' + window.location.hostname + (window.env === 'prod' ? '/api' : ':8984'), baseURL: 'http://' + window.location.hostname,
// withCredentials: true, // withCredentials: true,
crossorigin: true, crossorigin: true,
headers: { headers: {
+2 -1
View File
@@ -30,7 +30,8 @@ Vue.use(InfiniteLoading, {
Vue.use(VueScrollTo) Vue.use(VueScrollTo)
window.env = process.env // window.env = process.env
window.apipath = process.env === 'prod' ? '/api' : ':8984'
// sync(store, router) // done. Returns an unsync callback fn // sync(store, router) // done. Returns an unsync callback fn
+1 -1
View File
@@ -21,7 +21,7 @@ export default {
}), }),
beforeCreate () { beforeCreate () {
// ?_format=json // ?_format=json
REST.get(`/bibliography/works`, {}) REST.get(`${apipath}/bibliography/works`, {})
.then(({ data }) => { .then(({ data }) => {
console.log('Biblio REST: data', data) console.log('Biblio REST: data', data)
// if(data.length){ // if(data.length){
+3 -3
View File
@@ -126,7 +126,7 @@ export default {
console.log('texts this.$route', this.$route) console.log('texts this.$route', this.$route)
// http://localhost:8984/texts/gdpSauval1724/toc // http://localhost:8984/texts/gdpSauval1724/toc
// get the edition's toc // get the edition's toc
REST.get(`/texts/` + this.$route.params.id + `/toc`, {}) REST.get(`${apipath}/texts/` + this.$route.params.id + `/toc`, {})
.then(({ data }) => { .then(({ data }) => {
console.log('texts/toc REST: data', data) console.log('texts/toc REST: data', data)
this.meta = data.meta this.meta = data.meta
@@ -194,7 +194,7 @@ export default {
}), }),
getTextContent (textid, $state = null, direction = 'next') { getTextContent (textid, $state = null, direction = 'next') {
console.log('getTextContent', textid) console.log('getTextContent', textid)
REST.get(`/items/${textid}`, {}) REST.get(`${apipath}/items/${textid}`, {})
.then(({ data }) => { .then(({ data }) => {
console.log('text REST: data', data) console.log('text REST: data', data)
if (direction === 'next') { if (direction === 'next') {
@@ -248,7 +248,7 @@ export default {
}, },
getIndexItem (item) { getIndexItem (item) {
this.indexitem = 'loading' this.indexitem = 'loading'
REST.get(`/index${item.index.charAt(0).toUpperCase()}${item.index.slice(1)}/${item.uuid}`, {}) REST.get(`${apipath}/index${item.index.charAt(0).toUpperCase()}${item.index.slice(1)}/${item.uuid}`, {})
.then(({ data }) => { .then(({ data }) => {
console.log('index tooltip REST: data', data) console.log('index tooltip REST: data', data)
if (this.indexitem === 'loading') { if (this.indexitem === 'loading') {
+1 -1
View File
@@ -34,7 +34,7 @@ export default {
items: [] items: []
}), }),
beforeCreate () { beforeCreate () {
REST.get(`/indexLocorum`, {}) REST.get(`${apipath}/indexLocorum`, {})
.then(({ data }) => { .then(({ data }) => {
console.log('index locorum REST: data', data) console.log('index locorum REST: data', data)
if (data.content.length) { if (data.content.length) {
+1 -1
View File
@@ -37,7 +37,7 @@ export default {
beforeCreate () { beforeCreate () {
// items/gdpLeMaire1685T01BodyFr01.003.016 // items/gdpLeMaire1685T01BodyFr01.003.016
// texts/gdpSauval1724 // texts/gdpSauval1724
REST.get(`/indexNominum`, {}) REST.get(`${apipath}/indexNominum`, {})
.then(({ data }) => { .then(({ data }) => {
console.log('index nominum REST: data', data) console.log('index nominum REST: data', data)
if (data.content.length) { if (data.content.length) {
+1 -1
View File
@@ -34,7 +34,7 @@ export default {
items: [] items: []
}), }),
beforeCreate () { beforeCreate () {
REST.get(`/indexOperum`, {}) REST.get(`${apipath}/indexOperum`, {})
.then(({ data }) => { .then(({ data }) => {
console.log('index operum REST: data', data) console.log('index operum REST: data', data)
if (data.content.length) { if (data.content.length) {
+1 -1
View File
@@ -49,7 +49,7 @@ export default {
methods: { methods: {
loadItem () { loadItem () {
this.loaded = false this.loaded = false
REST.get(`/items/` + this.uuid, {}) REST.get(`${apipath}/items/` + this.uuid, {})
.then(({ data }) => { .then(({ data }) => {
console.log('item REST: data', data) console.log('item REST: data', data)
this.item = data.content this.item = data.content
+1 -1
View File
@@ -41,7 +41,7 @@ export default {
}, },
beforeCreate () { beforeCreate () {
console.log('locorum this.$route', this.$route) console.log('locorum this.$route', this.$route)
REST.get(`/indexLocorum/` + this.$route.params.id, {}) REST.get(`${apipath}/indexLocorum/` + this.$route.params.id, {})
.then(({ data }) => { .then(({ data }) => {
console.log('locorum REST: data', data) console.log('locorum REST: data', data)
if (data.content) { if (data.content) {
+1 -1
View File
@@ -40,7 +40,7 @@ export default {
}, },
beforeCreate () { beforeCreate () {
console.log('nominum this.$route', this.$route) console.log('nominum this.$route', this.$route)
REST.get(`/indexNominum/` + this.$route.params.id, {}) REST.get(`${apipath}/indexNominum/` + this.$route.params.id, {})
.then(({ data }) => { .then(({ data }) => {
console.log('nominum REST: data', data) console.log('nominum REST: data', data)
if (data.content) { if (data.content) {
+1 -1
View File
@@ -36,7 +36,7 @@ export default {
}, },
beforeCreate () { beforeCreate () {
console.log('operum this.$route', this.$route) console.log('operum this.$route', this.$route)
REST.get(`/indexOperum/` + this.$route.params.id, {}) REST.get(`${apipath}/indexOperum/` + this.$route.params.id, {})
.then(({ data }) => { .then(({ data }) => {
console.log('operum REST: data', data) console.log('operum REST: data', data)
if (data.content) { if (data.content) {
+2 -2
View File
@@ -57,7 +57,7 @@ export default {
}, },
// get authors // get authors
getAuthors ({ dispatch, commit, state }) { getAuthors ({ dispatch, commit, state }) {
return REST.get(`/corpus`, {}) return REST.get(`${apipath}/corpus`, {})
// .then(({ data }) => { // .then(({ data }) => {
// console.log('corpus getAuthors REST: data', data) // console.log('corpus getAuthors REST: data', data)
// commit('setAuthors', data.content) // commit('setAuthors', data.content)
@@ -70,7 +70,7 @@ export default {
// get editionslist // get editionslist
getEditionsList ({ dispatch, commit, state }, authors) { getEditionsList ({ dispatch, commit, state }, authors) {
return Promise.all(authors.map(function (author) { return Promise.all(authors.map(function (author) {
return REST.get(`/corpus/` + author.uuid, {}) return REST.get(`${apipath}/corpus/` + author.uuid, {})
.then(({ data }) => { .then(({ data }) => {
console.log('corpus getEditionsList REST: author, data', author, data) console.log('corpus getEditionsList REST: author, data', author, data)
// work arround // work arround
+1 -1
View File
@@ -41,7 +41,7 @@ export default {
} }
// console.log('Search getResults params', params); // console.log('Search getResults params', params);
let q = qs.stringify(params) let q = qs.stringify(params)
return REST.get(`/search?` + q) return REST.get(`${apipath}/search?` + q)
.then(({ data }) => { .then(({ data }) => {
console.log('search REST: data', data) console.log('search REST: data', data)
commit('setIsloading', false) commit('setIsloading', false)