I'm trying to make a simple GET request with clojurescript using cljs-ajax to a resource outside my server. My code core.cljs looks like this:
(ns btc-data-miner.core
(:require [clojure.browser.repl :as repl]
[ajax.core :refer [GET POST]]))
(defn handler [response]
(.log js/console (str response)))
(defn error-handler [{:keys [status status-text]}]
(.log js/console (str "something bad happened: " status " " status-text)))
(GET "www.okcoin.com/api/v1/ticker.do?symbol=btc_usd" {:handler handler
:error-handler error-handler})
But it always searches for files inside my website, as if a was passing /resource instead of the full path. How can I make the request to outside sources?
www.okcoin.com/api/v1/ticker.do?symbol=btc_usd
is a relative URL. So it will be resolved relative the current page (which, presumably, is on your server). If you want it to resolve to a different server, you need to use an absolute URL -- e.g.,http://www.okcoin.com/api/v1/ticker.do?symbol=btc_usd
.