Roman Glass Roman Glass - 1 year ago 116
Ajax Question

ClojureScript Ajax Output

GET is called and when referred to the handler. The result is not the data of the properties, the output is just "null". How can I output the needed value?

(ns places.core
(:require [ajax.core :refer [GET POST]]))

(defn handler [response]
(.log js/console (:sourceId (:_source (:hits (:hits response))))))

Answer Source

The solution was to parse the raw json output like this:

(defn handler [response]
  (.log js/console
        (.. (nth (.. (JSON/parse response) -hits -hits) 0) -_source -sourceId)))