Adding vendor import stuff.

This commit is contained in:
Bryce Covert
2018-05-10 17:32:22 -07:00
parent df3755d099
commit 798bfae78a
9 changed files with 173 additions and 32 deletions

View File

@@ -5,7 +5,7 @@
[cljs-time.coerce :as c]
[cljs-time.core :as time]
[cljs-time.format :as format]
[cljs.core.async :refer [<!]]
[cljs.core.async :refer [<! ] :as async]
[clojure.string :as str]
[clojure.walk :as walk]
[venia.core :as v]
@@ -68,6 +68,31 @@
(conj on-success)
(re-frame/dispatch)))))))
(re-frame/reg-fx
:https
(fn [{:keys [requests on-success on-failure]}]
(go
(let [results (->>
(for [{:keys [method body headers uri token]} requests]
(go
(let [headers (if token
(assoc headers "Authorization" (str "Token " token))
headers)
response (<! (http/request {:method method
:body body
:headers headers
:url uri}))]
(if (>= (:status response) 400)
:error
:success))))
(async/merge)
(async/reduce conj [])
(async/<!))]
(if (some #{:error} results)
(re-frame/dispatch on-failure)
(re-frame/dispatch on-success))))))
(defn kebab->snake [s]
(str/replace s #"-" "_"))