This commit is contained in:
scammo
2021-08-18 22:59:44 +02:00
parent 513d204d58
commit f0ef4e7f13
7 changed files with 141 additions and 126 deletions

View File

@ -63,8 +63,11 @@
</div>
</template>
<script>
import RequestMixin from "@/mixins/request.mixin"
export default {
name: "Search",
mixins: [RequestMixin],
data() {
return {
showErrorMessage: false,
@ -77,26 +80,5 @@ export default {
if (this.$route.query.query) this.searchText = this.$route.query.query;
this.submitSearch();
},
methods: {
async submitSearch() {
this.showErrorMessage = false;
try {
let url = `${this.apiUrl}/users/profiles`;
if (this.searchText != "") {
url += `?nickname=${this.searchText}`;
}
const result = await this.axios.get(url, {
headers: {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
});
this.searchResults = result.data.profiles;
this.searchTotal = result.data.total;
} catch (error) {
console.error(error);
this.showErrorMessage = true;
}
},
},
};
</script>