tryError Documentation
Function: tryMapAsync()Function
```ts function tryMapAsync<T, U, E>( resultPromise, mapper ): Promise<TryResult<U, TryError<string> | E>>; ``` Defined in: [async.ts:197](https://github.com/oconnorjohnson/try-error/blob/e3ae0308069a4fba073f4543d527ad76373db795/src/async.ts#L197) Transform a successful async result, leaving errors unchanged
tryError API Documentation v0.0.1-alpha.1
tryError API Documentation / tryMapAsync
Function: tryMapAsync()
function tryMapAsync<T, U, E>(
resultPromise,
mapper
): Promise<TryResult<U, TryError<string> | E>>;
Defined in: async.ts:197
Transform a successful async result, leaving errors unchanged
Type Parameters
T
T
U
U
E
E extends TryError<string>
Parameters
resultPromise
Promise<TryResult<T, E>>
Promise of TryResult to transform
mapper
(value) => Promise<U>
Async function to transform the success value
Returns
Promise<TryResult<U, TryError<string> | E>>
Promise of transformed result or original error
Example
const fetchResult = tryAsync(() => fetch("/api/user"));
const jsonResult = await tryMapAsync(fetchResult, async (response) =>
response.json()
);