(* 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-fetch
Then add bs-fetch
to bs-dependencies
in your bsconfig.json
:
{
...
"bs-dependencies": ["bs-fetch"]
}
See usage examples in examples/examples.ml
. The source is a single file!
Bs_fetch
module to Fetch
. Bs_fetch
is kept around as an alias for backwards compatibility, but should be considered deprecated.