         path           (apply str (map (partial str "/") endpoint-path))
         req-url        (if (nil? endpoint)
                          url
-                         ;(get-url endpoint)
-                          (str (get-url endpoint) path))
+                         ;;(get-url endpoint)
+                         (str (get-url endpoint) path))
 
         default-header {"Content-Type" "application/json" "Accept" "application/json"}
         optional-body  (if body
                          {"body" (js/JSON.stringify (clj->js body))}
                          {})
 
-        args (merge {
-                     "method"   method
+        args (merge {"method"   method
                      "credentials" "include"
                      "headers" (merge default-header headers)}
                     optional-body)

(ns trustroots.fetch-helper
  (:require
    [trustroots.helpers :refer [log info debug]]))



(def baseurl "https://www.trustroots.org/api")
(def url_map

                       error-type (cond
                                    ok nil
                                    (= status 403) :unauthorized
                                    :else :http-error)
                       handle-data (fn [data]
                                     (if ok
                                       (on-success {:data data :status status :ok ok})
                                       (on-error   {:data data :status status :type error-type})))
                       has-json (if (nil? parse-json) false
                                    parse-json)]

                   (-> (if has-json
                         (-> (.json res)
                             (.then #(js->clj %1 :keywordize-keys true))
                             (.then
                              #(if (vector? %1)
                                 (vec (map clojure.walk/keywordize-keys %1))
                                 %1)))
                         (.text res))
                       (.then #(do (log %) %))
                       (.then handle-data))))))))
