Skip to content

Response.functions.notOkEither

fx-fetch


fx-fetch / Response / 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.

E

R

Effect<Response, NotOkError | E, R>

Effect<Either<Response, Response>, E, R>

NotOkError for more details on the error type.

1.1.0

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
);
});