Skip to content

tryCatch

tryCatch<A>(f): TaskOption<A>

Defined in: Core/TaskOption.ts:55

Creates a TaskOption from a Promise-returning function. Returns Some if the promise resolves, None if it rejects.

A

() => Promise<A>

TaskOption<A>

const fetchUser = TaskOption.tryCatch(() =>
  fetch("/user/1").then(r => r.json())
);