Skip to content

readSafe

Reads the content of a file safely from the vault.

It covers the case when the file was removed during the reading.

Import:

import { readSafe } from 'obsidian-dev-utils/obsidian/vault';

Signature:

function readSafe(app: App, pathOrFile: PathOrFile): Promise<string | null>

Parameters:

ParameterTypeDescription
appAppThe application instance.
pathOrFilePathOrFileThe path or file to read.

Returns: Promise<string | null> — A Promise that resolves to the content of the file or null if the file is missing or deleted.