Fetch.variables.fetch
Variable: fetch()
Section titled “Variable: fetch()”
constfetch: (…args) =>Effect<Response,FetchError|AbortError|NotAllowedError|NotOkError,Fetch>
Defined in: packages/fx-fetch/src/Fetch/fetchFn.ts:37
Parameters
Section titled “Parameters”…[Request]
Returns
Section titled “Returns”Effect<Response, FetchError | AbortError | NotAllowedError | NotOkError, Fetch>
0.1.0
Example
Section titled “Example”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 programprogram.pipe( Effect.provideService(Fetch.Fetch, Fetch.FetchLive), Effect.runFork // or Effect.runPromise etc.);