Mashup of bs-fetch
and bs-node-fetch
All credit goes to those @glennsl and @arnarthor, see those repos for details.
BsNodeFetch.re
corresponds with the bs-node-fetch
master branch.
Fetch.re
corresponds with the bs-fetch
master branch.
FetchNext.re
corresponds with the bs-fetch-next
branch on bs-fetch
.
bs-fetch
is intended as a thin layer atop the JS API, upon which more high-level and idiomatic libraries can be made. Once such a library has been established, these bindings will likely be refactored to be even thinner.
bs-fetch
has a section explaining how to use that project on the server using isomorphic-fetch
.
Js.Promise.(
Fetch.fetch("https://dog.ceo/api/breeds/image/random/5")
|> then_(Fetch.Response.text)
|> then_(text => print_endline(text) |> resolve)
);
npm install --save https://github.com/idkjs/bs-fetcher
Then add bs-fetcher
to bs-dependencies
in your bsconfig.json
:
{
...
"bs-dependencies": ["bs-fetcher"]
}
Converting the bs-fetch
files to reason only seem to work if you use _method
signature to deal with the resevered method
keyword in bucklescript. In OCaml
syntax, method_
works.