0
const admin = require('firebase-admin');
admin.initializeApp({
 credential: admin.credential.cert(serviceAccount)
});

let fs = admin.firestore();
let auth = admin.auth();

    async function start (object){
  const info = await fs.collection('users').doc(object.uid).get();
  if (!liam.exists) {
    console.log('No document');
   } else {
    console.table([info.data()]);
   }
}

I want to send console.table([info.data()]); data to the webpage table, I can't send it to HTML with <script> tag and send data with document.getElement.

All I wanted is just send to viw in webpage insted of console, how can I do that?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
maharh
  • 1
  • 2
    You'll need to write a front end in something like React/Vue/Svelte for that – Mikkel Feb 20 '22 at 23:13
  • @Mikkel you can do it with plain Javascript – ManuelMB Feb 20 '22 at 23:28
  • @ManuelMB How to do it, can you please give me an example? – maharh Feb 20 '22 at 23:31
  • 1
    if you dont care about anything else in the document this will work `document.body.innerHTML = JSON.stringify(info.data(), null, 2)` depending on what info.data retunrs – eltonkamami Feb 20 '22 at 23:34
  • @eltonkamami the use of firebase-admin it's because he/she is working on the server side, not the front end, so he/she will need something like express to show the result in the front end. – ManuelMB Feb 20 '22 at 23:38
  • @eltonkamami It is giving error: **ReferenceError: document is not defined** – maharh Feb 20 '22 at 23:39
  • Take a look to this tutorial from Firebase. https://firebase.google.com/codelabs/firestore-web#0 – ManuelMB Feb 20 '22 at 23:40

0 Answers0