• Stars
    star
    200
  • Rank 195,325 (Top 4 %)
  • Language
    OCaml
  • License
    MIT License
  • Created over 7 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Fetch bindings for BuckleScript

melange-fetch

Low-level bindings to fetch for Melange.

Issues Last Commit

melange-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

opam pin add melange-fetch.dev git+https://github.com/melange-community/melange-fetch.git#master

Then add melange-fetch to the libraries field in your dune file:

(melange.emit ;; or (library ...)
 ...
 (libraries melange-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.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.

More Repositories

1

reason-react-hacker-news

hacker news mobile app made with reason react
Reason
592
star
2

bs-webapi-incubator

BuckleScript bindings to the DOM and other Web APIs
Reason
298
star
3

bs-express

Express bindings in Reason
ReScript
211
star
4

reason-apollo-hooks

Deprecated in favor of https://github.com/reasonml-community/graphql-ppx
Reason
137
star
5

reason-maze

JavaScript
103
star
6

bs-glamor

BuckleScript bindings for glamor
OCaml
83
star
7

bs-socket.io

Bindings to socket.io
Reason
50
star
8

belt

49
star
9

bsdoc

📚 Documentation Generator for BuckleScript
Reason
46
star
10

bs-immutablejs

Reason + BuckleScript bindings to Immutable.js
C++
29
star
11

bs-director

[UNMAINTAINED] BuckleScript bindings to the Director router
OCaml
23
star
12

bs-downshift

BuckleScript bindings for Downshift
OCaml
22
star
13

repacman

OCaml
22
star
14

error-message-improvement

Repo of issues that catalogues the compiler errors you'd like to see explained better in Reason
20
star
15

meta

Information about the reasonml-community organization and how it works
14
star
16

bs-glob

BuckleScript bindings to node-glob
OCaml
10
star
17

bs-transit-js

Transit-js bindings Bucklescript
Reason
10
star
18

bs-mocha

OCaml
8
star
19

bs-history

Bucklescript binding for history
OCaml
8
star
20

bs-discord.js

BuckleScript bindings for discord.js
Reason
6
star
21

bs-cookie-parser

cookie-parser binding in ReasonML
OCaml
5
star
22

bs-react-simple-maps

BuckleScript bindings for react-simple-maps
OCaml
5
star
23

bs-react-native

MOVED TO https://github.com/reason-react-native/bs-react-native
OCaml
2
star
24

reason-react-native

MOVED TO https://github.com/reason-react-native/reason-react-native
HTML
2
star