started search but api bugged
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="search">
|
<div id="search">
|
||||||
<form class="" action="index.html" method="post">
|
<form class="" action="index.html" method="post">
|
||||||
<label for="keywords">
|
<label for="keys">
|
||||||
Search
|
Search
|
||||||
<input
|
<input
|
||||||
id="keywords"
|
id="keys"
|
||||||
v-model="keywords"
|
v-model="keys"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="search"
|
placeholder="search"
|
||||||
>
|
>
|
||||||
@@ -24,24 +24,25 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import { mapState, mapActions } from 'vuex'
|
import { mapActions } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Search',
|
name: 'Search',
|
||||||
// data: () => ({
|
// data: () => ({
|
||||||
// keywords: ''
|
// typed: ''
|
||||||
// }),
|
// }),
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
keys: {
|
||||||
keywords: state => state.Search.keywords
|
get () { return this.$store.state.Search.keys },
|
||||||
})
|
set (value) { this.$store.commit('Search/setKeys', value) }
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions({
|
...mapActions({
|
||||||
getResults: 'Search/getResults'
|
getResults: 'Search/getResults'
|
||||||
}),
|
}),
|
||||||
submit () {
|
submit () {
|
||||||
console.log('submited', this.keywords)
|
console.log('submited', this.keys)
|
||||||
this.getResults()
|
this.getResults()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export default {
|
|||||||
|
|
||||||
// initial state
|
// initial state
|
||||||
state: {
|
state: {
|
||||||
keywords: '',
|
keys: '',
|
||||||
results: []
|
results: []
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -15,6 +15,9 @@ export default {
|
|||||||
|
|
||||||
// mutations
|
// mutations
|
||||||
mutations: {
|
mutations: {
|
||||||
|
setKeys (state, keys) {
|
||||||
|
state.keys = keys
|
||||||
|
},
|
||||||
setResults (state, content) {
|
setResults (state, content) {
|
||||||
state.results = content
|
state.results = content
|
||||||
}
|
}
|
||||||
@@ -23,12 +26,13 @@ export default {
|
|||||||
// actions
|
// actions
|
||||||
actions: {
|
actions: {
|
||||||
getResults ({ dispatch, commit, state }) {
|
getResults ({ dispatch, commit, state }) {
|
||||||
|
console.log('getResults', state.keys)
|
||||||
let params = {
|
let params = {
|
||||||
search: state.keywords
|
search: state.keys
|
||||||
}
|
}
|
||||||
// console.log('Search getResults params', params);
|
// console.log('Search getResults params', params);
|
||||||
let q = qs.stringify(params)
|
let q = qs.stringify(params)
|
||||||
return REST.post(`/search?` + q)
|
return REST.get(`/search?` + q)
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
console.log('search REST: data', data)
|
console.log('search REST: data', data)
|
||||||
// commit('setResults', data.content)
|
// commit('setResults', data.content)
|
||||||
|
|||||||
Reference in New Issue
Block a user