# bs-fetch

> Fetch bindings for BuckleScript

Latest version **0.6.2** (published 2020-07-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install bs-fetch
pnpm add bs-fetch
yarn add bs-fetch
bun add bs-fetch
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.6.2 |
| Published | 2020-07-16 |
| First published | 2017-05-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 45.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 207 |
| Author | glennsl |
| Maintainers | glennsl |
| Keywords | fetch, browser, xhr, bucklescript |

## Links

- npm: https://www.npmjs.com/package/bs-fetch
- Repository: https://github.com/reasonml-community/bs-fetch
- Homepage: https://github.com/reasonml-community/bs-fetch#readme
- Issues: https://github.com/reasonml-community/bs-fetch/issues
- npm.io page: https://npm.io/package/bs-fetch

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.6.2 (latest) — 2020-07-16
- 0.6.1 — 2020-06-07
- 0.6.0 — 2020-06-07
- 0.5.2 — 2020-02-22
- 0.5.1 — 2020-02-04
- 0.5.0 — 2019-06-20
- 0.4.0 — 2019-05-31
- 0.3.1 — 2018-10-27
- 0.3.0 — 2018-05-21
- 0.2.1 — 2018-01-21
- 0.2.0 — 2017-10-05
- 0.1.1 — 2017-05-15

## README

# bs-fetch

Low-level bindings to fetch for [BuckleScript](https://github.com/bucklescript/bucklescript).

[![npm](https://img.shields.io/npm/v/bs-fetch.svg)](https://npmjs.org/bs-fetch)
[![Issues](https://img.shields.io/github/issues/reasonml-community/bs-fetch.svg)](https://github.com/reasonml-community/bs-fetch/issues)
[![Last Commit](https://img.shields.io/github/last-commit/reasonml-community/bs-fetch.svg)]()
[![Size](https://img.shields.io/github/size/reasonml-community/bs-fetch/lib/js/src/Fetch.js.svg)]()

`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

```reason
Js.Promise.(
  Fetch.fetch("/api/hellos/1")
  |> then_(Fetch.Response.text)
  |> then_(text => print_endline(text) |> resolve)
);
```

## Installation

```sh
npm install --save bs-fetch
```

Then add `bs-fetch` to `bs-dependencies` in your `bsconfig.json`:
```js
{
  ...
  "bs-dependencies": ["bs-fetch"]
}
```

## Usage
See usage examples in [`ocaml_examples.ml`](https://github.com/reasonml-community/bs-fetch/blob/master/examples/ocaml_examples.ml) and [`reason_examples.re`](https://github.com/reasonml-community/bs-fetch/blob/master/examples/reason_examples.re). The source is a [single file](https://github.com/reasonml-community/bs-fetch/blob/master/src/Fetch.ml)!

## 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](https://github.com/matthew-andrews/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 `FormData` bindings

### 0.6.0
* Bugfix: `Response._type` was generating `_type` instead of `type`
* Breaking: Rename `Response._type` to `Response.type_` to follow the name mangling convention trends

### 0.5.2
* Added `AbortController`

### 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.

---
_Source: https://npm.io/package/bs-fetch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
