This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-16
Channels
- # beginners (176)
- # boot (11)
- # cider (12)
- # cljs-dev (65)
- # cljsrn (54)
- # clojars (18)
- # clojure (195)
- # clojure-austin (1)
- # clojure-dev (2)
- # clojure-italy (8)
- # clojure-quebec (1)
- # clojure-russia (51)
- # clojure-serbia (3)
- # clojure-spec (24)
- # clojure-uk (28)
- # clojurescript (41)
- # cursive (14)
- # data-science (60)
- # datascript (2)
- # datomic (111)
- # emacs (6)
- # figwheel (1)
- # graphql (16)
- # hoplon (26)
- # juxt (2)
- # lein-figwheel (3)
- # lumo (12)
- # off-topic (8)
- # om (14)
- # pedestal (22)
- # perun (2)
- # proton (1)
- # re-frame (29)
- # reagent (27)
- # ring (17)
- # ring-swagger (2)
- # rum (3)
- # spacemacs (3)
- # unrepl (155)
- # untangled (28)
- # vim (4)
(GET "/login" {params :params} (valid-login (params :username) (params :password)))
-> calls an ajax request and handles async response(defn valid-login [usuario senha]
(ajax/ajax-request
{:uri "https://******/login?$format=JSON"
:method :post
:params {:username usuario
:password senha}
:format (ajax/url-request-format)
:response-format (ajax/json-response-format {:keywords? true})
:error-handler #(response {:resposta "OK"})
:handler #(response {:resposta "OK"})
})
)
@fabrao Yes, you return a three-argument handler, like:
(GET "/login" [username password]
(fn [_ respond _]
(respond (valid-login username password))))
That’s using respond
synchronously, but you can pass it as a callback.
Or extend the compojure.response/Sendable
protocol for channels or some other asynchronous abstraction.
@weavejester I tested it but it´s getting "class ajax.apache$to_clojure_future$reify__72385 is not understandable"
Do you have the :async?
option set on the adapter? Are you using Compojure 1.6.0 and Ring 1.6.1? Are you trying to return some kind of custom async object?
[ring/ring-defaults "0.2.1"] [ring/ring-json "0.5.0-beta1"] [buddy/buddy-auth "1.4.1"] [compojure "1.5.0"]
You need to upgrade your dependencies, and you need to set :async? true
to your Jetty adapter.
Not sure. It might be an option. Take a look through the docs.
I need to go. bbl