user_search.js (556B)
1 import UserCard from '../user_card/user_card.vue'
2 import userSearchApi from '../../services/new_api/user_search.js'
3 const userSearch = {
4 components: {
5 UserCard
6 },
7 props: [
8 'query'
9 ],
10 data () {
11 return {
12 users: []
13 }
14 },
15 mounted () {
16 this.search(this.query)
17 },
18 watch: {
19 query (newV) {
20 this.search(newV)
21 }
22 },
23 methods: {
24 search (query) {
25 userSearchApi.search({query, store: this.$store})
26 .then((res) => {
27 this.users = res
28 })
29 }
30 }
31 }
32
33 export default userSearch