This commit is contained in:
Adrian Thompson
2020-08-28 17:01:53 +02:00
parent f785a111d8
commit 7b7895728b
4 changed files with 90 additions and 8 deletions

View File

@@ -26,7 +26,7 @@
</div>
</section>
<section class="buttons">
<button class="vin-button">Send inn denne som ønske</button>
<button class="vin-button" @click="request(wine)">Send inn denne som ønske</button>
<a
v-if="wine.vivinoLink"
:href="wine.vivinoLink"
@@ -58,10 +58,28 @@ export default {
methods: {
fetchWineFromVin(){
if(this.searchString){
searchForWine(this.searchString)
this.wines = []
let localSearchString = this.searchString.replace(/ /g,"_");
searchForWine(localSearchString)
.then(res => this.wines = res)
}
},
request(wine){
const options = {
body: JSON.stringify({
wine: wine
}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: "post"
}
fetch("http://localhost:30030/api/request", options)
.then(res => res.json())
.then(console.log)
}
},
}
</script>