Function then

  • Sets a promise then handler.

    Example

    const thenJson = then((response: Response) => response.json());

    thenJson(fetch("/api")); // Parsed response

    Returns

    Curried function with handler set in context.

    Type Parameters

    • HandlerInput

    • Output

    Parameters

    • handler: Unary<HandlerInput, Output | PromiseLike<Output>>

    Returns (<PromiseInstance>(promise: PromiseInstance) => Promise<Output>)

      • <PromiseInstance>(promise: PromiseInstance): Promise<Output>
      • Type Parameters

        • PromiseInstance extends Promise<HandlerInput, PromiseInstance>

        Parameters

        • promise: PromiseInstance

        Returns Promise<Output>