mirror of
https://github.com/status-im/status-mobile.git
synced 2025-02-11 16:17:13 +00:00
fix http-fetch: handle error status code
This commit is contained in:
parent
15d3d758ad
commit
9e509d2f9a
@ -44,8 +44,15 @@
|
|||||||
(-> (.fetch js/window url (clj->js {:method "GET"}))
|
(-> (.fetch js/window url (clj->js {:method "GET"}))
|
||||||
(.then (fn [response]
|
(.then (fn [response]
|
||||||
(log response)
|
(log response)
|
||||||
(.text response)))
|
[(.text response) (.-ok response)]))
|
||||||
(.then on-success)
|
(.then (fn [[response ok?]]
|
||||||
|
(cond
|
||||||
|
ok? (on-success response)
|
||||||
|
|
||||||
|
(and on-error (not ok?))
|
||||||
|
(on-error response)
|
||||||
|
|
||||||
|
:else false)))
|
||||||
(.catch (or on-error
|
(.catch (or on-error
|
||||||
(fn [error]
|
(fn [error]
|
||||||
(show-popup "Error" (str error))))))))
|
(show-popup "Error" (str error))))))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user