artanis
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

http-request in a controller- is it possible?


From: Mortimer Cladwell
Subject: http-request in a controller- is it possible?
Date: Thu, 3 Dec 2020 07:59:29 -0500

Hi,
Given the controller:

(register-define add
  (lambda (rc)
  (let* (
         ;;(btc-usd 18000)
            (btc-usd (string->number(receive (response-status response-body)
                                   (http-request "https://blockchain.info/q/24hrprice") response-body)))
          (btc-req (/ 5000 btc-usd))
               (currency-content (string-append " <option value=\"btc\">Bitcoin " (number->string btc-req) " BTC</option>)))
  (view-render "add" (the-environment)))
  ))

If I navigate to http://127.0.0.1:3000/register/add the browser hangs and eventually times out.

At the console:
Ragnarok: continue request
Error: (wrong-type-arg #f Wrong type (expecting ~A): ~S (resumable continuation #<vm-continuation 7f768042f930>) (#<vm-continuation 7f768042f930>))
Ingore it to avoid Ragnarok crash.
main-loop again

If at the REPL I evaluate (string->number (receive (response-status response-body)
     (http-request "https://blockchain.info/q/24hrprice") response-body))
I get a number e.g 18,123.45

If I comment out (btc-usd (string->number(receive.... ) and uncomment (btc-usd 18000), the expected page is rendered properly.

Is it possible to use (http-request... ) in a controller?
If not is there a workaround?
Thanks 
Mortimer

reply via email to

[Prev in Thread] Current Thread [Next in Thread]