API reference › @evolu/common › Result › 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
Resultto a nullable value for APIs that expectT | 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));