router, auth, edit, first autocomplete, bascis structure, no design

This commit is contained in:
scammo
2021-06-25 19:28:41 +02:00
parent 356aa738fb
commit 16b03bb5f2
9 changed files with 314 additions and 92 deletions

View File

@ -1,58 +1,66 @@
<template>
<div class="container">
<h1>Suche</h1>
<form @submit.prevent="submitSearch()">
<div class="row">
<div class="col">
<input
type="text"
class="form-control"
id="searchText"
v-model="searchText"
required
/>
</div>
<div class="col">
<button type="submit" class="btn btn-primary mb-4">Suche Starten</button>
</div>
<div class="row">
<div class="col">
<input
type="text"
class="form-control"
id="searchText"
v-model="searchText"
required
/>
</div>
<div class="col">
<button type="submit" class="btn btn-primary mb-4">
Suche Starten
</button>
</div>
</div>
</form>
<div class="alert alert-danger mb-4 mt-4" role="alert" v-if="showErrorMessage">
Bei der Suche ist ein Fehler aufgetreten
<div
class="alert alert-danger mb-4 mt-4"
role="alert"
v-if="showErrorMessage"
>
Bei der Suche ist ein Fehler aufgetreten
</div>
</div>
</template>
<script>
import axios from 'axios'
import axios from "axios";
export default {
name: 'Search',
data(){
return {
showErrorMessage: false,
searchText: '',
}
name: "Search",
data() {
return {
showErrorMessage: false,
searchText: "",
};
},
methods: {
async submitSearch(){
this.showErrorMessage = false
try{
const loginResult = await axios.post(
`${process.env.VUE_APP_API_URL}/search`,
// Beispiel Hafte Daten
{
searchText: this.searchText,
})
if(loginResult.status === 200){
//success login
this.router.push({path: 's/search'})
}
else{
this.showErrorMessage = true
}
}catch(error){
console.error()
this.showErrorMessage = true
async submitSearch() {
this.showErrorMessage = false;
try {
const loginResult = await axios.post(
`${process.env.VUE_APP_API_URL}/search`,
// Beispiel Hafte Daten
{
searchText: this.searchText,
}
);
if (loginResult.status === 200) {
//success login
this.router.push({ path: "s/search" });
} else {
this.showErrorMessage = true;
}
} catch (error) {
console.error();
this.showErrorMessage = true;
}
}
}
},
},
};
</script>