node package manager
Stop wasting time. Easily manage code sharing in your team. Create a free org »

bs-fetch

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-fetch

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

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

Usage

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

Changes

0.2.0

  • Rename Bs_fetch module to Fetch. Bs_fetch is kept around as an alias for backwards compatibility, but should be considered deprecated.