  validate-spec
  (fn [cofx [_ stories]]
    {:db (-> (update (:db cofx) :stories #(concat % stories))
-            (update-in [:front-page :current-page-num] inc))
-    }))
+            (update-in [:front-page :current-page-num] inc))}))
 
 (reg-event-fx
  :failed-loading-front-page-stories
  validate-spec
  (fn [cofx [_ error-response]]
    (throw (ex-info (str error-response "Failed loading stories") {:response error-response}))
-   {:db (:db cofx)}
-   ))
+   {:db (:db cofx)}))
 
 (reg-event-fx
  :loaded-story-comments


(def hn-api "https://node-hnapi.herokuapp.com")

(defn fetch
  [url params on-success]
  (-> (js/fetch (str hn-api "/news" "?page=1") (clj->js params))
      (.then js->clj)
      (.then #(js/console.log %))
      (.catch #(js/console.error %))))

(reg-event-fx
 :load-front-page-stories
 (fn [{:keys [db]} [_]]
   {:http-xhrio {:method          :get
                 :uri             (str hn-api "/news")
                 :params {:page  (get-in db [:front-page :current-page-num])}
                 :timeout         8000
                 :response-format (ajax/json-response-format {:keywords? true})
                 :on-success      [:loaded-front-page-stories]

(reg-event-fx
 :load-story-comments
 (fn [{:keys [db]} [_ story-id]]
   {:fetch-http{:method          :get
                :url             (str hn-api "/item/" story-id)
                :timeout         8000
                :response-format (ajax/json-response-format {:keywords? true})
                :on-success      [:loaded-story-comments]
                :on-failure      [:failed-loading-story-comments]}}))

(reg-event-fx
 :open-story-external
