package melange-fetch
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=c92c5bb7b3d19b43177e86c10fcab2694cdca981d065ae4ebc7234aa811665ef
sha512=8a989b972aff865fa796e203ba19604e122ddb1fc555fe71b295dbf158055f6253a64a709014cfe55b1200fcc72793a438db41997ce28bf47cad6a6214c7655d
Description
Published: 28 Nov 2025
README
melange-fetch
Low-level bindings to fetch for Melange.
melange-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.
Example
Js.Promise.(
Fetch.fetch("/api/hellos/1")
|> then_(Fetch.Response.text)
|> then_(text => print_endline(text) |> resolve)
);Installation
opam install melange-fetchThen add melange-fetch to the libraries field in your dune file:
(melange.emit ;; or (library ...)
...
(libraries melange-fetch))Usage
See usage examples in ocaml_examples.ml and reason_examples.re. The source is a single file!
Node.js polyfill
fetch is a Web API that isn't available out-of-the-box in Node.js, and will therefore need to be polyfilled. isomorphic-fetch one such polyfill that seems to work well. Just install it via npm and add [%raw "require('isomorphic-fetch')"] to the top of your main file, but be aware that there are some subtle differences and even parts that are missing entirely.
Changes
0.6.2
- Added
FormDatabindings
0.6.0
- Bugfix:
Response._typewas generating_typeinstead oftype - Breaking: Rename
Response._typetoResponse.type_to follow the name mangling convention trends
0.5.2
- Added
AbortController
0.5.0
- Fixed
Headers.appendandHeaders.delete. They were missing the return type.
0.4.0
- Bumped
bs-platformto 5.0.4 to stop compiler from complaining.
0.3.0
- Added
HeadersInit.makeWithDictso as to be able to make headers in OCaml too - Require
bs-platform>= 3.0.0 due to internal dependency on Js.boolean that has now been removed
0.2.0
- Rename
Bs_fetchmodule toFetch.Bs_fetchis kept around as an alias for backwards compatibility, but should be considered deprecated.
Dev Dependencies (4)
-
ocaml-lsp-server
with-dev-setup -
ocamlformat
with-dev-setup -
reason
with-dev-setup -
odoc
with-doc
Used by (1)
Conflicts
None