happy-rusty
    Preparing search index...

    Type Alias AsyncOption<T>

    AsyncOption: Promise<Option<T>>

    Represents an asynchronous Option that is wrapped in a Promise. This type alias is used for functions that perform asynchronous operations and return an Option as the result.

    Type Parameters

    • T

      The type of the value that may be contained in the Some variant.

    1.5.0

    async function fetchUser(id: number): AsyncOption<User> {
    const response = await fetch(`/users/${id}`);
    if (response.ok) {
    return Some(await response.json());
    }
    return None;
    }