arod1207
arod1207

Reputation: 79

Trying to access this to query. First timer using firebase

I am trying to query a single document. Here is my current code. Been on this for hours and can't seem to get it to work. Bet its an easy fix

export function GetSingleTicket() {
  const docRef = doc(db, "tickets", "hg7G40Lhwh9HVwqe4mlB");

  getDoc(docRef).then((doc) => {
    console.log(doc.data(), doc.id);
  });
}

firebase document tree

Upvotes: 0

Views: 51

Answers (1)

Chanpols
Chanpols

Reputation: 1702

As mentioned by @Frank van Puffelen Property names are case-sensitive. And according to your code the collection name is in small letters.

Solution:

export function GetSingleTicket() {
  const docRef = doc(db, "Tickets", "hg7G40Lhwh9HVwqe4mlB");

  getDoc(docRef).then((doc) => {
    console.log(doc.data(), doc.id);
  });
}

Upvotes: 1

Related Questions