Bindings to fetch for BuckleScript.
(* 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)
);npm install --save bs-node-fetchThen add bs-node-fetch to bs-dependencies in your bsconfig.json:
{
...
"bs-dependencies": ["bs-node-fetch"]
}See usage examples in examples/examples.ml. The source is a single file!
This is a fork from bs-fetch with minor modifications for node-fetch. All credits go to the authors of that package.