Genie Discord forum
I'm using the new framework (e.g. @page...). Is there a way to access query parameters? For example, if I have a dashboard.jl file, and within I have
and I request this page with https://localhost:8000/people?lastname=Smith&firstname=Bob
Is there a way to access those query parameters (e.g. so that UI elements are filled in from a database lookup with that name) from within dashboard.jl ?
I know you can get those from within a a call to route using getpayload https://genieframework.github.io/Genie.jl/dev/API/requests.html#Genie.Requests.getpayload
Here's an example for uploading files https://genieframework.com/blog/how-to-build-a-data-app-with-a-CSV-file-uploader/index.html
Right - that works for POST, but doesn't seem to work for GET
As @Pere pointed out, have you tried using getpayload?
Thanks - all of those answers are good, but don't fit my problem. Using the new framework (e.g.
@page("ui.jl.html") ) , functions from the model don't see
getparameters (just gets an empty dictionary). But, if I call a function from the UI page, like ```
<% reportText(Genie.Requests.getpayload()) %>
then I can pass in the query parameters and do something with them. The `reportText` function is defined in the model Julia file.
@lyonsquark good question
it's important to keep in mind that the app has multiple "stages" - the initial one is when the page is rendered in the browser, sending the HTML from the view, injecting the necessary JS files, and setting up the websocket connection to the backend. This is the request that has the
beyond this point, the data sync for the reactivity is done over websockets, using different requests
these requests do not have the
so the subsequent requests after the page is loaded are over websockets and different from the original request
so you need to capture the params from the initial page request - so you can use them later on
you can store them in a private var
(well, best to store just
params()[:GET] to use less memory
mmm... sorry, scrap that, it doesn't work reliably
I think it worked by accident
I need to dig some more
ok, this is the best I could come up with
Thanks @essenciary - I'm actually making a dynamic page (it's a report), so simply doing
<% makeReport(getpayload()) %> works great. But, I do have some form pages that I would like pre-filled in based on the URL query parameters, so I'll try that for those pages. Thanks again!