Skip to content

Instantly share code, notes, and snippets.

@HilmiZul
Last active February 14, 2022 04:30
Show Gist options
  • Save HilmiZul/791da2250e5982f1c19835ee619700b2 to your computer and use it in GitHub Desktop.
Save HilmiZul/791da2250e5982f1c19835ee619700b2 to your computer and use it in GitHub Desktop.
<template>
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>Products</h1>
<div class="row">
<div v-for="produk in products" :key="produk.id" class="col-md-4">
<div class="card mb-4">
<div class="card-header">
<img :src="produk.foto" width="100%" class="img-thumb">
</div>
<div class="card-body">
<h4>{{ produk.nama }}</h4>
<h4>Rp{{ produk.harga }}</h4>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
products: '',
}
},
mounted() {
this.getProducts()
},
methods: {
async getProducts() {
let {data, error} = await this.$supabase
.from('tb_produk')
.select()
if(data) this.products = data
if(error) console.error(error)
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment