Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
Update function to Firebase V9 with nextjs

I have updated my project with version 9 of firebase and I started to have some code errors that I still can't solve.

the previous function looks like this. and I need to update it for the new firebase V9 version

const doc = await firebaseApp
  .firestore()
  .collection('documents')
  .doc(params.documento)
  .get();

if (!doc) {
  return {
    notFound: true,
  };
}

const data = doc.data();

return {
  props: {
    texto: {
      ...data,
      fecha: data?.fecha?.toDate().toLocaleString('es-ES', { timeZone: 'UTC', day: '2-digit', month: 'long', year: 'numeric' }),
    },
  },
};
}



about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I found a way to solve this problem.


    const snapshot = await getDocs (collection(db, 'documents')); 
    const paths = snapshot.docs.map(doc => {
      
      return {
        params: {
          documento: doc.id.toString()
        }
      }
    })

    return {
      paths,
      fallback: false
    }
}

export const getStaticProps = async (context) => {
  const documento = context.params.documento;

  const docRef = doc(db, 'documents', documento);
  const docSnap = await getDoc(docRef);

  return {

    props: {textoProps: JSON.stringify(docSnap.data()) || null}

  }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!