0
votes

I have this code:


      (do 
               ;**[1]** 
        (.start (Thread. 
          (http/get "http://127.0.0.1:8001/cardiologista/api/auth/ms1"
                       {:query-params {:verify "my-hash"}}))
        )
            ;**[2]**
        (.start (Thread. 
               (let [session (:session request)]
                   (-> (redirect "/client/dashboard")
                       (assoc :session verifica))))
        )
      )

I want to make a get call ([1]) and I don't want to wait for the callback (I won't use the callback), however, I don't want to wait for the response from that call to redirect ([2]) the page, I tried to do it that way (using thread), but it didn't work right.

In short: I want to make a GET call [1] and after that call to call the redirect function [2], but I cannot wait for the GET call to respond. (I don't know if this would solve using thread)

1
Do you really need 2 threads? Your "redirect" logic should probably run in the current thread, so no need to create a new thread for that. Also I'd probably use futures instead of threads.Julio
Thank you very much, I used the future and solved the problem. I didn't really know this functionPedro Augusto Null

1 Answers

0
votes

As the friend said in the comments, I used future to solve the problem, the function was like this:

(do 
  (future 
    (http/get "http://127.0.0.1:8001/cardiologista/api/auth/ms1"
              {:query-params {:verify "my-hash"}}))
  (let [session (:session request)]
    (-> (redirect "/cliente/dashboard")
        (assoc :session verifica))))