BuckleScript bindings for Substack's hyperquest (http-client) library.
npm install bs-hyperquestBuckleScript bindings for substack's [hyperquest] library.
#### GET
``reasonresponse(
let result =
Js.Promise.make((~resolve, ~reject) =>
Hyperquest.get(~uri, ())
|. Hyperquest.on(
res => {
let data = ref("");
res
|. Hyperquest.IncomingMessage.on(
data(error(exn => reject(. exn)),
b => data := data^ ++ Hyperquest.Buffer.toString(b),
),
)
|. Hyperquest.IncomingMessage.on(
)
|. Hyperquest.IncomingMessage.on(
end_(_ => resolve(. data^)),`
)
|. ignore;
},
),
)
|. ignore
);
#### GET
`reasonerror(exn)) => exn |. Js.String.make |. fail |. finish
Hyperquest.Future.get(~uri, ())
|. Future.mapOk(((_, data)) => data)
|. Future.mapError(res =>
switch(res) {
| (_,
| (_, response(data)) => data |. fail |. finish``
}
)
|. ignore
[hyperquest]: https://github.com/substack/hyperquest
[reason-future]: https://github.com/RationalJS/future