Skip to content

Fetch.functions.fetchText

fx-fetch


fx-fetch / Fetch / fetchText

fetchText(request): Effect<string, MalformedTextError | FetchError | AbortError | NotAllowedError | NotOkError, Fetch>

Defined in: packages/fx-fetch/src/Fetch/fetchText.ts:36

Fetches and reads a text response.

Request

Effect<string, MalformedTextError | FetchError | AbortError | NotAllowedError | NotOkError, Fetch>

0.1.0

Response.readText

import { Effect } from 'effect';
import { Fetch, Request, Response } from 'fx-fetch';
// ┌─── Effect.Effect<
// │ void,
// │ | Fetch.FetchError
// │ | Fetch.AbortError
// │ | Fetch.NotAllowedError
// │ | Response.NotOkError
// │ | MalformedTextError,
// │ Fetch.Fetch
// │ >
// ▼
const program = Effect.gen(function* () {
const request = Request.unsafeMake({ url: './my-endpoint' });
// ┌─── string
// ▼
const payload = yield* Fetch.fetchText(request);
});