Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including bs-fetch with all npm packages installed. Try it out:

bs-fetch lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

require("bs-platform/package.json"); // bs-platform is a peer dependency. // require("bs-fetch/[??]")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

bs-fetch v0.5.0

Fetch bindings for BuckleScript


Low-level bindings to fetch for BuckleScript.

npm Issues Last Commit Size

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.


  |> then_(Fetch.Response.text)
  |> then_(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 and 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.



  • Fixed Headers.append and Headers.delete. They were missing the return type.


  • Bumped bs-platform to 5.0.4 to stop compiler from complaining.


  • Added HeadersInit.makeWithDict so 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


  • Rename Bs_fetch module to Fetch. Bs_fetch is kept around as an alias for backwards compatibility, but should be considered deprecated.
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free