Guys, does anyone know how to pass url parameters out of order?
Examples
/cars/key1=value1&key2=value2&key3=value3
or
/cars/key3=value3&key1=value1&key2=value2
or
/cars/key2=value2&key3=value3&key1=value1
I need to send these parameters out of order, how do I retrieve and assemble the routes?
franse
September 25, 2023, 10:10pm
2
I need to pass the parameters without depending on the previous ones, I need to pass the key3 parameter without having to pass the key2 parameter.
Example
/cars/key1/key2/key3
/cars/key2
/cars/key3/key1
But I can’t because the route doesn’t accept it and gives an error!
franse
September 25, 2023, 10:55pm
4
Well, that won't be possible, please note that optional parameters won't work if they're in the middle.
From the Route Properties => /cars/key2
is: /cars//key2
Maybe you can find a workaround from this:
When defining a dynamic link href or the like, you can do something like:
for
path: "/people/:people_id/:business_id?"
the link could be
dmx-bind:href="'/people/'+peopleval.default('x')+'/'+businessval.default('x')"
Using the script below, I was able to get the variables even out of order, now I need to know how to call these variables within Wappler and be able to use their value to create a filter.
<script>
//console.log ("Window Location:", window.location);
const myKeysValues = window.location.search;
//console.log("Keys & Values:", myKeysValues);
const urlParams = new URLSearchParams(myKeysValues);
const param1 = urlParams.get('key1');
const param2 = urlParams.get('key2');
const param3 = urlParams.get('key3');
console.log("01=", param1);
console.log("02=", param2);
console.log("03=", param3);
</script>
HOW ARE THE ROUTES!
LINK / CONSOLE