Skip to content

Latest commit

 

History

History
51 lines (40 loc) · 1010 Bytes

README.md

File metadata and controls

51 lines (40 loc) · 1010 Bytes

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
);