Refactor user search api, better api error response handling

This commit is contained in:
Tae Hoon 2019-07-10 16:58:49 +00:00 committed by Shpuld Shpludson
parent 2f87540612
commit 532b76eb64
7 changed files with 31 additions and 79 deletions

View file

@ -35,15 +35,13 @@ const userSearch = {
},
search (query) {
if (!query) {
this.users = []
return
}
this.loading = true
this.userIds = []
this.$store.dispatch('searchUsers', query)
.then((res) => {
this.loading = false
this.userIds = map(res, 'id')
})
.then((res) => { this.userIds = map(res, 'id') })
.finally(() => { this.loading = false })
}
}
}