Fork me on GitHub
#cljsrn
<
2017-01-20
>
edwthomas23:01:06

@ejelome here’s a sample of my code that worked with Fetch.

edwthomas23:01:58

(-> (js/fetch "" (clj->js {:method  "GET"}))
    (.then (fn [response]
             (-> (.json response)
                 (.then (fn [user]
                          (dispatch [:some-event (js->clj user :keywordize-keys true)]))))))
    (.catch (error-handler-fn))) 

edwthomas23:01:59

hope this helps. I normally use the anonymous function shorthand but in this case, I liked the readability of the explicit fn call. Also dispatch is a re-frame function. You could replace it with any success handler function.