Fetch.functions.fetchJson
Function: fetchJson()
Section titled “Function: fetchJson()”fetchJson(
request):Effect<unknown,MalformedJsonError|FetchError|AbortError|NotAllowedError|NotOkError,Fetch>
Defined in: packages/fx-fetch/src/Fetch/fetchJson.ts:36
Fetches and reads a JSON response.
Parameters
Section titled “Parameters”request
Section titled “request”Returns
Section titled “Returns”Effect<unknown, MalformedJsonError | 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// │ | MalformedJsonError,// │ Fetch.Fetch// │ >// ▼const program = Effect.gen(function* () { const request = Request.unsafeMake({ url: './my-endpoint' });
// ┌─── unknown // ▼ const payload = yield* Fetch.fetchJson(request);});