started search form and store

This commit is contained in:
2019-08-23 19:17:07 +02:00
parent 07f35b0e89
commit b8fc27a93d
5 changed files with 88 additions and 8 deletions
+3 -2
View File
@@ -2,11 +2,12 @@ import Vue from 'vue'
import Vuex from 'vuex'
import Corpus from './modules/corpus'
import Search from './modules/search'
Vue.use(Vuex)
export default new Vuex.Store({
modules: {
Corpus
// search
Corpus,
Search
}
})
+42
View File
@@ -0,0 +1,42 @@
import { REST } from 'api/rest-axios'
import qs from 'querystring'
export default {
namespaced: true,
// initial state
state: {
keywords: '',
results: []
},
// getters
getters: {},
// mutations
mutations: {
setResults (state, content) {
state.results = content
}
},
// actions
actions: {
getResults ({ dispatch, commit, state }) {
let params = {
search: state.keywords
}
// console.log('Search getResults params', params);
let q = qs.stringify(params)
return REST.post(`/search?` + q)
.then(({ data }) => {
console.log('search REST: data', data)
// commit('setResults', data.content)
})
.catch((error) => {
console.warn('Issue with search', error)
Promise.reject(error)
})
}
}
}