 
 (defn- update-note [{:keys [note-id] :as note} rsp-ch]
   (go
-    (let [srv-ch (http/put (str "/note/" note-id) {:query-params (get-update-note-params note)})
-          {:keys [status body]} (<! srv-ch)]
+    (let [{:keys [status body]} (<! (http/put (str "/note/" note-id) {:query-params (get-update-note-params note)}))]
       (case status
         200 (put! rsp-ch {:ok? true})
-        401 (put! rsp-ch {:ok? false})
-        (println "hmz") ; TODO: define return value {:ok? true/false :}
+        (put! rsp-ch {:ok? false :error body})
   ))))
 
 (defn- get-note [note-id rsp-ch]

;     (DELETE url {:handler #(println "yay")})))
  )



(defn get-private-notes [user-id rsp-ch]
  (go
    (let [srv-ch (http/get "/note" {})
          {:keys [status body]} (<! srv-ch)]
      (case status
        200 (put! rsp-ch {:ok? true :notes (reverse body)})
        401 (put! rsp-ch {:ok? false})
        (println "hmz") ; TODO: define return value {:ok? true/false :}
  ))))



; (defn get-public-notes
;   []
;   ; TODO: implement backend
;   )



(defn create-note [user-id text visibility rsp-ch]
  (go
    ; TODO: change "query-params" - I want form-params
    (let [srv-rsp (<! (http/post "/note" {:query-params {:text text :visibility visibility}}))]
      (case (:status srv-rsp)
        200 (put! rsp-ch {:ok? true :note (:body srv-rsp)})
        (println "uh oh, note not created!" srv-rsp) ; (put! rsp-ch (:body srv-rsp)) ; TODO: parse this..
  ))))

(defn- delete-note [note-id rsp-ch]
  (go
    (let [srv-rsp (<! (http/delete (str "/note/" note-id)))]
      (case (:status srv-rsp)
        200 (put! rsp-ch {:ok? true})
        (println "ooops, couldn't delete note" note-id)
  ))))

(defn- get-update-note-params [{:keys [note-id text visibility] :as note}]

            [cljs-http.client :as http]
  ))

;;; server operations

(defn- get-sign-url [type]
  (case type
    :sign-in "/user/session"
    :sign-up "/user"))

(defn- sign [type user pass rsp-ch]
  (go
