0.2.0 • Published 1 year ago

@glennsl/rescript-fetch v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

rescript-fetch

Zero-cost rescript bindings to the WHATWG Fetch API

npm Issues Last Commit

Example

let postBanana = async data => {
  open Fetch

  let response = await fetch(
    "/api/bananas",
    {
      method: #POST,
      body: data->Js.Json.stringifyAny->Belt.Option.getExn->Body.string,
      headers: Headers.fromObject({
        "Content-type": "application/json",
      }),
    },
  )

  await response->Response.json
}

See examples for more.

Installation

npm install --save @glennsl/rescript-fetch

Then add @glennsl/rescript-fetch to bs-dependencies in your bsconfig.json:

 {
   "bs-dependencies": [
+    "@glennsl/rescript-fetch"
   ]
 }

Documentation

API

For the moment, please see the interface file:

Changes

0.2.0

  • BREAKING Updated required minimum version of rescript to 10.1.2 in order to use the new promise type alias and async/await.
  • Removed @ryyppy/rescript-promise dependency.

0.1.0

Initial release

0.2.0

1 year ago

0.1.2

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago