This commit is contained in:
@ -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>
|
||||
|
Reference in New Issue
Block a user