bs-node-fetch

0.3.0 • Public • Published

Bindings to fetch for BuckleScript.

Example

(* OCaml *)
let _ =
  Js.Promise.(
    fetch "/api/hellos/1"
    |> then_ Response.text
    |> then_ (fun text -> print_endline text |> resolve)
  )
/* Reason */
Js.Promise.(
  fetch "/api/hellos/1"
  |> then_ Response.text
  |> then_ (fun text => print_endline text |> resolve)
);

Installation

npm install --save bs-node-fetch

Then add bs-node-fetch to bs-dependencies in your bsconfig.json:

{
  ...
  "bs-dependencies": ["bs-node-fetch"]
}

Usage

See usage examples in examples/examples.ml. The source is a single file!

Alternatives

bs-fetch has a section explaining how to use that project on the server using isomorphic-fetch. I personally need to use node-fetch therefor I maintain these bindings.

Credits

The initial bindings are a fork from bs-fetch with minor modifications for node-fetch. Credit to the authors of that package for a great foundation.

Some minor additions have been made for node-fetch.

Package Sidebar

Install

npm i bs-node-fetch

Weekly Downloads

55

Version

0.3.0

License

MIT

Unpacked Size

32.2 kB

Total Files

17

Last publish

Collaborators

  • arnar