 (register-handler
   :initialize
   (fn [app-state _]
-    (dispatch [:set-token (get-cookie :token)])
+    (dispatch [:set-token (cookies/get :token nil)])
     (merge app-state {:ui-state {:is-busy?      false
                                  :section       :login
                                  :current-query ""

  (fn [app-state [_ token]]
    (if (not-empty token)
      (dispatch [:set-message ""]))
    (set-cookie :token token)
    (-> app-state
        (assoc-in [:credentials :token] token)
        (assoc-in [:ui-state :section] (if (empty? token) :login :write))

(ns memento.core
  (:require [ajax.core :refer [GET POST PUT]]
            [clojure.string :refer [trim split]]
            [reagent.cookies :as cookies]
            [reagent.core :as reagent :refer [atom]]
            [re-frame.core :refer [dispatch register-sub register-handler subscribe dispatch-sync]]
            [goog.events :as events]
