Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

153
Vistas
orderByChild is not a function

i am trying to fetch filtered data from my firebase database in reactjs web application.i do it as follow, but it gives this error that..orderByChild is not a functionwhat's going on, i cants understand.

import fb from '../../firebase';
const DB =fb.firestore();
const restro_list = DB.collection('restros');
const[restros, Setrestros] = useState([]);

useEffect(()=>{
    const unsubrestro = restro_list.orderByChild('MealType').on('value', snapshot => {
       snapshot.forEach(docu => {
          const data = docu.docs.forEach(doc => ({
             ...doc.val(),
             id: doc.id,
           }));
           Setrestros(data);
        });
   });
   return unsubrestro;
 },[]);

but this always give me error.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The orderByChild() is a function in Firebase Realtime Database SDK but you are using Firestore where you should use orderBy() as shown below:

const unsubrestro = restro_list.orderBy("MealType").onSnapshot((snapshot) => {
  const data = snapshot.docs.map((d) => ({ id: d.id, ...d.data() }))
  Setrestros(data);
})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda