Response.functions.notOkEither
fx-fetch / Response / notOkEither
Function: notOkEither()
Section titled “Function: notOkEither()”notOkEither<
E,R>(self):Effect<Either<Response,Response>,E,R>
Defined in: packages/fx-fetch/src/Response/notOkEither.ts:39
Encapsulates both success Response and NotOkError failure of an Effect into an Either type of Response.
Type Parameters
Section titled “Type Parameters”E
R
Parameters
Section titled “Parameters”Effect<Response, NotOkError | E, R>
Returns
Section titled “Returns”Effect<Either<Response, Response>, E, R>
NotOkError for more details on the error type.
1.1.0
Example
Section titled “Example”import { Effect, Either } from 'effect';import { Fetch, Request, Response } from 'fx-fetch';
// ┌─── Effect.Effect<// │ void,// │ | Fetch.FetchError// │ | Fetch.AbortError// │ | Fetch.NotAllowedError// │ Fetch.Fetch// │ >// ▼const program = Effect.gen(function* () { const request = Request.unsafeMake({ url: './my-endpoint' });
// ┌─── Either.Either< // │ Response.Response, // Ok response 200-399 // │ Response.Response // NotOk response 400-599 // │ > // ▼ const result = yield* Fetch.fetch(request).pipe( Response.notOkEither );});