Git Product home page Git Product logo

bs-fetch's Introduction

bs-fetch

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.

Example

Js.Promise.(
  Fetch.fetch("/api/hellos/1")
  |> then_(Fetch.Response.text)
  |> then_(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 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.5.0

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

0.4.0

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

0.3.0

  • 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

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.

bs-fetch's People

Contributors

alextes avatar chenglou avatar flash-gordon avatar glennsl avatar jmuhlich avatar joprice avatar mransan avatar relekang avatar romanschejbal avatar yihangho avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.