[Top][All Lists]

[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

Given the controller:

(register-define add
  (lambda (rc)
  (let* (
         ;;(btc-usd 18000)
            (btc-usd (string->number(receive (response-status response-body)
                                   (http-request "") 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 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 "") 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?

reply via email to

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