Skip to content

tryCatch

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

Defined in: Core/TaskMaybe.ts:56

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

A

() => Promise<A>

TaskMaybe<A>

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