Importing jsons from Firestore

Answered
Youssef Shabo asked on February 14, 2024

Hello all, 

I've been developing a vite-react app that utilizes flexmonster and in this app I'm able to save the data from the table as a josn to my app's Firestore. But I'm having an inssue importing the same data back into the flexmonster's table. here's the function for it:

  // ================== Function to Fetch from Firestore
  const fetchTableData = async () => {
    const docRef = doc(
      db,
      "userID-001",
      "views",
      "viewID-001",
      "page-table-001"
    );

    try {
      const docSnap = await getDoc(docRef);
      if (docSnap.exists()) {
        console.log("Table data fetched:", docSnap.data());
        setTableData(docSnap.data().data);
      } else {
        console.log("No such document!");
      }
    } catch (error) {
      console.error("Error fetching table data:", error);
    }
  };
please note that I see the data coming in the console log but nothing is showing up in the table itself! I appreciate the help.

3 answers

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster February 16, 2024

Hello Youssef,

Thank you for reaching out to us.

We recommend using Flexmonster API to connect to the data source. Please check the following guide for more details: https://www.flexmonster.com/doc/json-data-source/ 
One thing to keep in mind is that JSON data should be specified in one of the following formats:

  • An array of objects, where each object is an unordered set of key-value pairs.
  • An array of arrays, where the first array contains field names, while other arrays are an ordered collection of values.

Feel free to check the following section for the examples: https://www.flexmonster.com/doc/json-data-source/#prerequisites 
Could you please specify how you pass the data to Flexmonster? Also, are there any errors or messages in the browser's developer console? It would greatly help us.

Please let us know if it works for you. Looking forward to hearing from you.

Kind regards,
Nadia

Public
Youssef Shabo February 21, 2024

Thanks you for your help Nadia! The issue was solved! 

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster February 22, 2024

Hello Youssef,

Thank you for the feedback!

We are glad to hear that it works for you. 

Feel free to reach out to us in case other questions arise.

Kind regards,
Nadia

Please login or Register to Submit Answer