API reference@evolu/commonResult › getOrNull

function getOrNull<T, E>(result: Result<T, E>): T | null;

Defined in: packages/common/src/Result.ts:376

Extracts the value from a Result if it is an Ok, or returns null if it is an Err.

Intended usage:

  • When you need to convert a Result to a nullable value for APIs that expect T | null.
  • When the error is not important and you just want the value or nothing.

Example

// For APIs that expect T | null
const user = getOrNull(findUser(id));