tryError Documentation
Function: tryChainAsync()
Function
```ts function tryChainAsync<T, U, E1, E2>( resultPromise, chainer ): Promise<TryResult<U, E1 | E2>>; ``` Defined in: [async.ts:253](https://github.com/oconnorjohnson/try-error/blob/e3ae0308069a4fba073f4543d527ad76373db795/src/async.ts#L253) Chain async operations that return Promise<TryResult>, short-circuiting on errors
tryError API Documentation v0.0.1-alpha.1
tryError API Documentation / tryChainAsync
Function: tryChainAsync()
function tryChainAsync<T, U, E1, E2>(
resultPromise,
chainer
): Promise<TryResult<U, E1 | E2>>;
Defined in: async.ts:253
Chain async operations that return Promise<TryResult>, short-circuiting on errors
Type Parameters
T
T
U
U
E1
E1
extends TryError
<string
>
E2
E2
extends TryError
<string
>
Parameters
resultPromise
Promise
<TryResult
<T
, E1
>>
Promise of TryResult to chain from
chainer
(value
) => Promise
<TryResult
<U
, E2
>>
Async function that takes success value and returns new Promise<TryResult>
Returns
Promise
<TryResult
<U
, E1
| E2
>>
Promise of chained result or first error encountered
Example
const result = await tryChainAsync(
tryAsync(() => fetch("/api/user")),
async (response) => tryAsync(() => response.json())
);