The Firebase JS SDK is now in BETA!
This EAP site is no longer maintained. See the official Firebase Documentation site for the latest documentation and information about the Firebase JS SDK.

Home > @firebase/firestore > / > DocumentSnapshot > get

DocumentSnapshot.get() method

Retrieves the field specified by fieldPath. Returns undefined if the document or field doesn't exist.

By default, a FieldValue.serverTimestamp() that has not yet been set to its final value will be returned as null. You can override this by passing an options object.

Signature:

get(fieldPath: string | FieldPath, options?: SnapshotOptions): any;

Parameters

Parameter Type Description
fieldPath string | FieldPath The path (for example 'foo' or 'foo.bar') to a specific field.
options SnapshotOptions An options object to configure how the field is retrieved from the snapshot (for example the desired behavior for server timestamps that have not yet been set to their final value).

Returns:

any

The data at the specified field location or undefined if no such field exists in the document.