ki-frontend/src/views/Search.vue

61 lines
1.3 KiB
Vue
Raw Normal View History

2021-06-07 17:41:25 +02:00
<template>
<div class="container">
2021-06-07 17:41:25 +02:00
<h1>Suche</h1>
<form @submit.prevent="submitSearch()">
<div class="row">
<div class="col">
<input
type="text"
class="form-control"
id="searchText"
v-model="searchText"
/>
2021-06-07 17:41:25 +02:00
</div>
<div class="col">
<button type="submit" class="btn btn-primary mb-4">
Suche Starten
</button>
</div>
</div>
2021-06-07 17:41:25 +02:00
</form>
<div
class="alert alert-danger mb-4 mt-4"
role="alert"
v-if="showErrorMessage"
>
Bei der Suche ist ein Fehler aufgetreten
2021-06-07 17:41:25 +02:00
</div>
</div>
2021-06-07 17:41:25 +02:00
</template>
<script>
export default {
name: "Search",
data() {
return {
showErrorMessage: false,
searchText: "",
};
2021-06-07 17:41:25 +02:00
},
methods: {
async submitSearch() {
this.showErrorMessage = false;
try {
2021-07-26 17:10:28 +02:00
const result = await this.axios.get(
`${process.env.VUE_APP_API_URL}/users/profiles`,
{
2021-07-26 17:10:28 +02:00
headers: {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
2021-06-07 17:41:25 +02:00
}
);
2021-07-26 17:10:28 +02:00
console.log(result)
} catch (error) {
2021-07-26 17:10:28 +02:00
console.error(error);
this.showErrorMessage = true;
2021-06-07 17:41:25 +02:00
}
},
},
};
2021-06-07 17:41:25 +02:00
</script>