first api request for search is working
This commit is contained in:
@@ -3,48 +3,47 @@ import { print } from 'graphql/language/printer'
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
// import REST from '@api/rest-axios'
|
||||
import GQL from '@api/graphql-axios'
|
||||
// import GQL from '@api/graphql-axios'
|
||||
// import JSONAPI from '@api/json-axios'
|
||||
import MA from '@api/ma-axios'
|
||||
import qs from 'querystring-es3'
|
||||
|
||||
import StaticsFields from '@api/gql/statics.fragment.gql'
|
||||
// import StaticsFields from '@api/gql/statics.fragment.gql'
|
||||
|
||||
export const SearchStore = defineStore({
|
||||
id: 'search',
|
||||
state: () => ({
|
||||
// loaded: false,
|
||||
keys: null,
|
||||
contentTypesFilter: [],
|
||||
results: []
|
||||
}),
|
||||
getters: {
|
||||
|
||||
},
|
||||
actions: {
|
||||
setKeys (value) {
|
||||
this.keys = value.split(' ');
|
||||
},
|
||||
setContentTypes (v) {
|
||||
this.contentTypesFilter = v
|
||||
},
|
||||
loadResults () {
|
||||
console.log('search store loadResults');
|
||||
// return new Promise((resolve, reject) => {
|
||||
// const ast = gql`{
|
||||
// promotedstatics {
|
||||
// ...StaticsFields
|
||||
// }
|
||||
// }
|
||||
// ${StaticsFields}
|
||||
// `
|
||||
// console.log('ast', ast);
|
||||
// GQL.post('', { query: print(ast) })
|
||||
// .then(({ data : { data : { promotedstatics } } }) => {
|
||||
// console.log('loadstatics loaded', promotedstatics)
|
||||
// this.statics = promotedstatics
|
||||
|
||||
// promotedstatics.forEach((s) => {
|
||||
// // console.log("s", s);
|
||||
// this.statics_byid[s.id] = s
|
||||
// });
|
||||
// console.log("statics_byid", this.statics_byid);
|
||||
// this.loaded = true;
|
||||
// })
|
||||
// .catch(error => {
|
||||
// console.warn('Issue with loadStatics', error)
|
||||
// Promise.reject(error)
|
||||
// })
|
||||
// })
|
||||
console.log('search store loadResults', this.keys);
|
||||
// this.keys = keys;
|
||||
const params = {
|
||||
keys: this.keys.join(', ')
|
||||
}
|
||||
const q = qs.stringify(params)
|
||||
return MA.get('/ouatt_searchapi/getresults?' + q)
|
||||
.then(({ data }) => {
|
||||
console.log('search MA getresults data', data, data.nids)
|
||||
this.results = data.nids;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.warn('Issue with getResults', error)
|
||||
// window.location.reload()
|
||||
Promise.reject(error)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
Reference in New Issue
Block a user