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

export default userSearch