Skip to content

Fetch.variables.fetch

fx-fetch


fx-fetch / Fetch / fetch

const fetch: (…args) => Effect<Response, FetchError | AbortError | NotAllowedError | NotOkError, Fetch>

Defined in: packages/fx-fetch/src/Fetch/fetchFn.ts:37

…[Request]

Effect<Response, FetchError | AbortError | NotAllowedError | NotOkError, Fetch>

0.1.0

import { Effect } from 'effect';
import { Fetch, Request, Response } from 'fx-fetch';
// ┌─── Effect.Effect<
// │ void,
// │ | Fetch.FetchError
// │ | Fetch.AbortError
// │ | Fetch.NotAllowedError
// │ | Response.NotOkError,
// │ Fetch.Fetch
// │ >
// ▼
const program = Effect.gen(function* () {
const request = Request.unsafeMake({ url: './my-endpoint' });
// ┌─── Response.Response
// ▼
const response = yield* Fetch.fetch(request);
});
// Run the program
program.pipe(
Effect.provideService(Fetch.Fetch, Fetch.FetchLive),
Effect.runFork // or Effect.runPromise etc.
);