From 9e509d2f9a57e5cc8c3c91095c8a69c00df144ee Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Tue, 7 Mar 2017 12:36:13 +0200 Subject: [PATCH] fix http-fetch: handle error status code --- src/status_im/utils/utils.cljs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/status_im/utils/utils.cljs b/src/status_im/utils/utils.cljs index 5212c22f7e..5754a47081 100644 --- a/src/status_im/utils/utils.cljs +++ b/src/status_im/utils/utils.cljs @@ -44,8 +44,15 @@ (-> (.fetch js/window url (clj->js {:method "GET"})) (.then (fn [response] (log response) - (.text response))) - (.then on-success) + [(.text response) (.-ok response)])) + (.then (fn [[response ok?]] + (cond + ok? (on-success response) + + (and on-error (not ok?)) + (on-error response) + + :else false))) (.catch (or on-error (fn [error] (show-popup "Error" (str error))))))))