Skip to main content

Reading data

Sometimes you just need to fetch data once without subscribing to ongoing changes. The Lark SDK provides two equivalent methods for this.

once(eventType)

Reads data at a reference and returns a promise that resolves with a DataSnapshot:

get()

An alias for once('value'). Same behavior, shorter syntax:

Working with snapshots

Both methods return a DataSnapshot. Here are the key properties and methods:

snapshot.val()

Returns the data as a JavaScript value (object, array, string, number, boolean, or null):

snapshot.exists()

Returns true if data exists at this location, false if it’s null:

snapshot.key

The key (last path segment) of the location this snapshot represents:
If you need data that stays up to date as it changes, use real-time subscriptions instead. once() and get() fetch a single point-in-time snapshot and don’t update afterward.