KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Using query parameters to send web variables to On Web Connection
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: July 22, 2025

When developing APIs for dynamic web pages, a common pattern is to send request variables via query parameters with a JavaScript fetch call that is executed from an event listener. For example, the following fetch call could be executed from the web client after a user clicks a button:

fetch(`https://my.do.main/hello?foo=${bar}&bax=${qux}`)

In the On Web Connection database method, the query parameter variables can be parsed using WEB GET VARIABLES. Then, some tasks would be performed depending on the URL path. Since the URL extra data parameter ($1) extracts the full path, it is common to disregard the query string and focus on the initial path:

// ON WEB CONNECTION
ARRAY TEXT($names; 0)
ARRAY TEXT($values; 0)

WEB GET VARIABLES($names; $values)

$url:=$1

Case of
   : ($url="/hello?@")
   // Do some tasks with variables in $values…
End case

In the ‘Case of’ statement, notice how a wildcard character is used to match all paths that contain ‘/hello’, regardless of the query string used to transmit the web variables.