funcool / funcool/httpurr

node client does not reject promise on unsucessful request

Open
#30 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Clojure
Stars
67
Forks
16
PR merge metrics
No merged PRs in 30d

Description

```clj
(require '[httpurr.client.node :as node])
(require '[promesa.core :as p])

(defn decode
[response]
(update response :body #(js->clj (js/JSON.parse %))))

(defn get!
[url]
(p/then (node/get url) decode))
```

This is an example from the docs. In contrast to the `client/send!` function this won't automatically reject the promise if the request failed. Edit, it seems that even when using `client/send!` and passing the node client a 400 HTTP code does not cause the promise to be rejected. I'm wondering if this should be considered a bug or if using client specific `send!` functions should be discouraged / removed from the docs?

I find this behavior is probably worth fixing as the documentation describes multiple ways of making requests with different error handling semantics.

From the docs

> `send!` is a function that, given a request map and optionally a map of options, performs the request and returns a promise that will be resolved if there is a response and **rejected on timeout, exceptions, HTTP errors** or aborts.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.