Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (5)


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



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


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(