fetch-native-lwt
v0.1.0-alpha.5
Published
Fetch client (Lwt) for native ReasonML/OCaml
Downloads
1
Readme
fetch-native-lwt
Fetch client for native ReasonML.
Getting started
- 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>"
- Add Fetch to your dune libraries:
(libraries ... fetch-native-lwt)
- 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
);