fetch-native-lwt

0.1.0-alpha.5 • Public • Published

fetch-native-lwt

Fetch client for native ReasonML.

Getting started

  1. Install

Currently to install, you'll need esy and pin fetch-native-lwt to point to this Github-repo.

{
  "dependencies": {
    "fetch-native-lwt": "lessp/fetch:fetch-native-lwt.json"
  }
}

or, to point to a specific commit:

"fetch-native-lwt": "lessp/fetch:fetch-native-lwt.json#<commit-hash>"
  1. Add Fetch to your dune libraries:
(libraries ... fetch-native-lwt)
  1. Make your first request:
Fetch.(
  get("https://httpbin.org/get")
  |> Lwt.map(
       fun
       | Ok({Response.body, status, url, headers}) => {
           Printf.printf(
             "Headers: \n%sStatus-Code: %d\nBody: %s\nUrl: %s",
             Response.Headers.toString(headers),
             Response.Status.toCode(status),
             Response.Body.toString(body),
             url,
           );
         }
       | Error(e) => Printf.printf("That's an error: %s", e),
     )
  |> Lwt_main.run
);

Readme

Keywords

none

Package Sidebar

Install

npm i fetch-native-lwt

Weekly Downloads

0

Version

0.1.0-alpha.5

License

MIT

Unpacked Size

7.31 kB

Total Files

11

Last publish

Collaborators

  • lessp