mk / fetch

ClojureScript wrapper for the JavaScript fetch API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lambdaisland/fetch

CircleCI cljdoc badge Clojars Project

ClojureScript wrapper around the JavaScript fetch API.

(require '[lambdaisland.fetch :as fetch])

(fetch/get "/foo.json")
#<promise
  {:status 200
   :headers {...}
   :body #js {...}}>

(fetch/post "/foo.transit" {:query-params {:foo "123"}
                            :body {:hello "world"}})
#<promise
  {:status 200
   :headers {...}
   :body #js {...}}>
  • Simply uses promises (add kitchen-async if you like it sweeter)
  • Returns a promise which delivers something akin to a ring response map
  • Does basic content negotiation and encoding/decoding of request/response body
  • Defaults to Transit

Support Lambda Island Open Source

If you find value in our work please consider becoming a backer on Open Collective

Contributing

Everyone has a right to submit patches to this projects, and thus become a contributor.

Contributors MUST

  • adhere to the LambdaIsland Clojure Style Guide
  • write patches that solve a problem. Start by stating the problem, then supply a minimal, accurate solution. *
  • agree to license their contributions as MPLv2.
  • not break the contract with downstream consumers. **
  • not break the tests.

Contributors SHOULD

  • update the CHANGELOG and README.
  • add tests for new functionality.

If you submit a pull request that adheres to these rules, then it will almost certainly be merged immediately. However some things may require more consideration. If you add new dependencies, or significantly increase the API surface, then we need to decide if these changes are in line with the project's goals. In this case you can start by writing a pitch, and collecting feedback on it.

* This goes for features too, a feature needs to solve a problem. State the problem it solves, then supply a minimal solution.

** As long as this project has not seen a public release (i.e. is not on Clojars) we may still consider making breaking changes, if there is consensus that the changes are justified.

License

Copyright © 2020 Arne Brasseur and Contributors

Licensed under the term of the Mozilla Public License 2.0, see LICENSE.

About

ClojureScript wrapper for the JavaScript fetch API

License:Mozilla Public License 2.0


Languages

Language:Clojure 82.0%Language:Emacs Lisp 13.1%Language:HTML 4.2%Language:Shell 0.7%