mini-effect
    Preparing search index...

    Function bytes

    • Reads the response body as a Uint8Array.

      Parameters

      • response: Response

        The Response whose body to read

      Returns Effect<Uint8Array<ArrayBuffer>, Failure<"FailedToRead">, never, never>

      An Effect that resolves with a Uint8Array or fails with a FailedToRead tagged error

      Wraps Response.bytes() in an Effect. If reading fails, the error is wrapped in a FailedToRead tagged error that can be caught with catchTags.

      import { pipe, run } from "mini-effect";
      import { request, bytes } from "mini-effect/fetch";

      const data = await run(
      pipe(request("https://example.com/file.bin"), (res) => bytes(res)),
      );