> For the complete documentation index, see [llms.txt](https://demystifyfp.gitbook.io/fstoolkit-errorhandling/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/asyncresult/foldresult.md).

# foldResult

### AsyncResult.foldResult

Namespace: `FsToolkit.ErrorHandling`

Function Signature:

```fsharp
('a -> 'b) -> ('c -> 'b) -> Async<Result<'a, 'c>> -> Async<'b>
```

This is just a shortcut for `Async.map Result.fold`. See [Result.fold](/fstoolkit-errorhandling/fstoolkit.errorhandling/result/fold.md) for more.

### Examples

#### Example 1

```fsharp
type HttpResponse<'a, 'b> =
  | Ok of 'a
  | InternalError of 'b

// CreatePostRequest -> Async<Result<PostId, exn>>
let createPost (req : CreatePostRequest) = async {
  // ...
}

// Async<HttpResponse>
let handler (httpReq : HttpRequest) = 
  // ... 
  
  // Async<Result<PostId, exn>>
  let createPostAR = createPost httpReq

  createPostAR
  |> AsyncResult.fold Ok InternalError
```
