1.6.4 • Published 10 months ago

@prelude-io/fetch v1.6.4

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

@Prelude-IO/Fetch

npm version documentation

Prelude-IO aims to provide easy to use run- and compiletime type-safety combined with the benefits of immutability through Prelude-ts. This library adds a simple wrapper around fetch, to type-check your request and response bodies.

Example

import * as io from "@prelude-io/core";
import { ioFetch } from "@prelude-io/fetch";

const CatFact = io.Complex("CatFact", {
  fact: io.string,
  length: io.positiveNumber,
});

const CatFactsResponse = io.Complex("CatFactsResponse", {
  factCount: io.positiveNumber,
  facts: io.Vector(CatFact),
});

const CatFactRequest = io.JSON.chain(
  io.Complex("CatFactRequest", {
    facts: io.number,
  })
);

const catFactFetch = ioFetch(CatFactsResponse, CatFactRequest);

const result = await catFactFetch("https://catfacts.example.com", {
  body: { facts: 4 },
});

console.log(result); // => IORight containing `{ factCount: 4, facts: [...] }`

Documentation

You can read typedoc documentation here

Installation

npm install --save @prelude-io/core @prelude-io/fetch prelude-ts
1.6.4

10 months ago

1.6.3

11 months ago

1.6.2

1 year ago

1.6.1

1 year ago

1.5.2

1 year ago

1.6.0

1 year ago

1.5.1

1 year ago

1.6.0-alpha.0

1 year ago

1.5.0

1 year ago

1.4.0

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.3

1 year ago