request

The request keyword returns a reference to the current HTTP request object (see javax.servlet.http.HttpServletRequest). It can be used to access HTTP GET request parameters.

Example

The request object of a page that was accessed with the URL

http://127.0.0.1:8082/structr/rest/my-page?name=test&value=123

looks like this:

request.name = "Test"
request.value = 123

Note

To access parameters from HTTP POST requests, please use the retrieve() function.

Warning

If you are running methods from a Cron job, the request object is null, so if you are using that method in another context where you want to supply request parameters, in order for it to stay error-free in the Cron context, you need to null-check the request.

let request = Structr.get('request');
if (Structr.empty(request)) {
    // empty request so we are probably in a Cron context
}
About this article
Last change 2019-02-28
Topics FrontendStructr 2.0