export async function search(data) {
return new Promise(async (resolve, reject) => {
try {
data = {
...getDataForList.call(this),
dynamic_pagination_count: this.perPageCount,
token: store.state.login.token,
uid: store.state.login.uid
};
if(store.state.login.isAdmin){
data.ouid = store.state.login.uid
if(this.listingSearchFilters.username){
data.username = this.listingSearchFilters.username
}
if(this.searchListing) {
data.username = this.searchListing;
}
}
await this.$nextTick();
this.$eventHub.$emit("show-full-loading");
const res = await this.axios.post("/api/v1/search", qs.stringify(data), {
auth: this.apiAuth,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
}
});
this.$eventHub.$emit("hide-full-loading");
resolve(res.data);
} catch (error) {
this.$eventHub.$emit("hide-full-loading");
reject(error);
}
});
}