Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

How i can pass firebase data to customers


import firebase from "firebase/app";
import { defineComponent, ref, onMounted } from "vue";

interface ICustomer {
id: number;
name: string;
email: string;
}

const customers: Array<ICustomer> = [
{
id: Math.floor(Math.random() * 99999) + 1,
name: "Emma Smith",
email: "e.smith@kpmg.com.au",
},
{
id: Math.floor(Math.random() * 99999) + 1,
name: "Melody Macy",
email: "melody@altbox.com",
},
];

firebase
.firestore()
.collection("Spark/Datos/Usuarios")
.onSnapshot((querySnapshot) => {
interface ICustomer {
id: number;
name: string;
email: string;
}
const data: Array<ICustomer> = [];
querySnapshot.forEach((doc) => {
data.push({
id: doc.data().id,
name: doc.data().name,
email: doc.data().email
});
return data
});
console.log("VACIO: ", JSON.parse(JSON.stringify(data)));
console.log("LLENO: ", JSON.parse(JSON.stringify(data)));
});


export { ICustomer };

export default customers;


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (5)


Hi,

customers.ts is a file mostly for the demo purpose, so in a real app, it is better to fetch data inside a separate vuex module and then display the vuex store in the component.

Please check our KTDatatable component doc to get more info about the usage.
https://preview.keenthemes.com/metronic8/vue/docs/#/setup-theme-skeleton



Hi, I have too many days try datatable work with firebase, i cant, only can see data in console.

can you please sent my code sample firebase datatable.
i have too many days and cant make this work!!

please....

regards

my code

<script lang="ts">
import { defineComponent, ref, onMounted, } from "vue";
import Datatable from "@/components/kt-datatable/KTDatatable.vue";
import ExportCustomerModal from "@/components/modals/forms/ExportCustomerModal.vue";
import AddCustomerModal from "@/components/modals/forms/AddCustomerModal.vue";
import { setCurrentPageBreadcrumbs } from "@/core/helpers/breadcrumb";
import firebase from "firebase/app";
export default defineComponent({
name: "customers-listing",
components: {
Datatable,

},
data() {
return {
count: 1,
tableData: ref<any>([]),
tableHeader: ref([
{
key: "checkbox",
sortable: false,
},
{
name: "Customer Name",
key: "name",
sortable: true,
},
{
name: "Email",
key: "email",
sortable: true,
},
{
name: "Actions",
key: "actions",
},
])
}
},

mounted() {
firebase
.firestore()
.collection("Spark/Datos/Usuarios")
.onSnapshot((querySnapshot) => {
let data: any[] = []
console.log("VACIO: ", JSON.parse(JSON.stringify(this.tableData)));

querySnapshot.forEach((doc) => {
data.push({
id: doc.data().id,
name: doc.data().name,
email: doc.data().email
});
this.tableData = data

});
console.log("VACIO: ", JSON.parse(JSON.stringify(data)));
return data = this.tableData

});
}
})
</script>



Hi,

At the moment we do not have a solution related to firebase.

If you are able to get your data in the console then could you please try to assign the table Data array as shown below?


tableData.value.splice(0, tableData.value.length, ...dataFromFirebase.value);



Thanks this work!!!

I want to now if I can pay for custom, i need disable your API and login wth firebase. I will pay for this?

or can please send me dev contact i will pay for changes?

thanks



Hi,

If you want to request additional development, you can leave a request on the "Hire us" page.
https://keenthemes.com/hireus?_ga=2.33417911.844364091.1644133725-898876560.1640377949


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(