Skip to content

flash-gordon/bs-fetch

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bs-fetch

Low-level bindings to fetch for BuckleScript. 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.

Example

(* 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)
);

Installation

npm install --save bs-fetch

Then add bs-fetch to bs-dependencies in your bsconfig.json:

{
  ...
  "bs-dependencies": ["bs-fetch"]
}

Usage

See usage examples in examples/examples.ml. The source is a single file!

Changes

0.2.0

  • Rename Bs_fetch module to Fetch. Bs_fetch is kept around as an alias for backwards compatibility, but should be considered deprecated.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • OCaml 56.7%
  • JavaScript 43.3%