get
Retrieve data from the Realtime Database once.
Overview
The get method reads data at a specified path exactly once. This is useful for data that doesn't change frequently or when you don't need real-time updates.
Getting data
import { db } from 'refirebase';
const data = await db.realtime.get('config/settings');
if (data && !('error' in data)) {
console.log('Settings retrieved:', data);
} else {
console.error('Failed to get data', data?.error);
}
Parameters
| Param | Type | Description |
|---|---|---|
path* | string | The path to the data in the Realtime Database. |
Return value
Returns
Promise<T | null | { error: unknown }>The data at the path, null if it doesn't exist, or an error object if the operation fails.