add search functionality

This commit is contained in:
Adrian Thompson
2020-08-27 13:25:44 +02:00
parent 5fc3bca01a
commit 09f0436f98
5 changed files with 112 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
<template>
<main>
<h1>
Anbefal en vin!
</h1>
<section>
<input type="text" v-model="searchString" >
<button @click=(fetchWineFromVin())>knapp</button>
<div v-for="(wine, index) in this.wines" :key="index">
<Wine :wine=wine >
<button>Pick</button>
</Wine>
</div>
</section>
</main>
</template>
<script>
import { searchForWine } from "@/api";
import Wine from "@/ui/Wine";
export default {
components: {
Wine
},
data() {
return {
searchString: undefined,
res: undefined,
wines: undefined,
}
},
methods: {
fetchWineFromVin(){
searchForWine(this.searchString)
.then(res => this.wines = res)
},
},
}
</script>
<style>
</style>