Home > @firebase/firestore > / > getDoc
getDoc() function
Reads the document referred to by this DocumentReference
.
Note: getDoc()
attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke getDocFromCache() or getDocFromServer().
Signature:
export declare function getDoc<T>(reference: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
Parameters
Parameter | Type | Description |
---|---|---|
reference | DocumentReference<T> | The reference of the document to fetch. |
Returns:
Promise<DocumentSnapshot<T>>
A Promise resolved with a DocumentSnapshot
containing the current document contents.