@yamadayuki/bs-axios

0.1.0 • Public • Published

bs-axios

url module bindings for BuckleScript in Reason.

Installation

  1. Install @yamadayuki/bs-axios
$ npm install --save @yamadayuki/bs-axios
  1. Add @yamadayuki/bs-axios to bs-dependencies section of bsconfig.json.

Usage

Perfoming a GET request

open Js.Promise;

Axios.get("/users?id=12345")
|> then_(res => resolve(Js.log(res##data)))
|> catch(err => resolve(Js.log(err)))

/* With config for authentication */
Axios.getWithConfig("/users?id=12345", Axios.makeConfig(~auth={"username": "foo", "password": "bar"}, ()))
|> then_(res => resolve(Js.log(res##data)))
|> catch(err => resolve(Js.log(err)))

Performing a POST request

open Js.Promise;

postData("/users", {"firstName": "Fred", "lastName": "Flintstone"})
|> then_(res => resolve(Js.log(res##data)))
|> catch(err => resolve(Js.log(err)))

TODO

  • Support axios.spread
  • Consider Interceptors

Contributing

Build

npm run build

Build + Watch

npm run start

Editor

If you use vscode, Press Windows + Shift + B it will build automatically

Readme

Keywords

Package Sidebar

Install

npm i @yamadayuki/bs-axios

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

12.9 kB

Total Files

8

Last publish

Collaborators

  • yamadayuki