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

154
Views
Filter firebase firestore data in react js

I'm trying to perform a filter and sort query, but I want to put it inside a function. How can I do that ?

I'm trying to do this

const handleFilter = () => {
  const q = query(collection(db, "location"), where ("location", "==", "Pasig"));

  const querySnapshot = await getDocs(q);

  querySnapshot.forEach((doc) => {
    (doc.id, " => ", doc.data());
  });
}

But it is not working.

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

To use await keyword inside a function it needs to be declared as an async function. Try the following:

const handleFilter = async () => {
const q = query(
  collection(db, "location"),
  where("location", "==", "Pasig")
);

const querySnapshot = await getDocs(q);

querySnapshot.forEach((doc) => {
  doc.id, "=>", doc.data();
});
about 4 years ago · Santiago Gelvez 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!