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

175
Views
FirebaseError: Expected type 'Ea', but it was: a custom Na object

i was following along the guidelines that firebase provides and i ran into this error.


  const [orders, setOrders] = useState([]);
  useEffect(() => {
    const getData = async () => {
      if (user) {
        const collRef = getDocs(db, "users", user?.id);
        const orderedRef = query(collRef, orderBy("created", "desc"));
        const docSnap = await onSnapshot(orderedRef);
        setOrders(docSnap);
        orders.map((doc) => ({
          id: doc.id,
          data: doc.data(),
        }));
      } else {
        setOrders([]);
      }
    };
    getData();
  }, [user]);

and i get this

Orders.jsx:36 Uncaught (in promise) FirebaseError: Expected type 'Ea', but it was: a custom Na object

--UPDATE--

I just wanted to point out that I'm new to firebase and I was following a video guide that is from a couple years ago and they weren't using the v9 modular style.

From their video their code goes as follows:

  useEffect(() => {
    if(user) {
        db
        .collection('users')
        .doc(user?.uid)
        .collection('orders')
        .orderBy('created', 'desc')
        .onSnapshot(snapshot => (
            setOrders(snapshot.docs.map(doc => ({
                id: doc.id,
                data: doc.data()
            })))
        ))
    } else {
        setOrders([])
    }

  }, [user])

I am trying to emulate this function using the v9 modular style but am running into some issues.

almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

if you are using a query there is no need to use the getDocs. You may check this documentation for examples.

Sample Code:

    const collRef = collection(db,"users","user?.id","orders")
    const orderedRef = query(colRef, orderBy("created", "desc"));
    onSnapshot(orderedRef, (querySnapshot) => {
        setOrders(
            querySnapshot.docs.map((doc) => ({
                id: doc.id,
                data: doc.data(),
            }))
        );
    });
almost 4 years ago · Santiago Trujillo 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!