How to retrieve parameters by route - Node JS

Excellent thanks.

Is much slicker than my solution when I get it to work.

If I add it to the view or layout page I get:

Screenshot 2021-02-09 at 09.00.21

What’s the piece of code? Just assigning it to a Wappler var?

Edit: I’ve just tested it in a partial and a layout and I have no issues retrieving the parameter.

Tested in layout and in view.

Screenshot 2021-02-09 at 09.50.32

you can see the value above using the js script

When using dmx-bind the value should be an expression, so add extra quotes.

<dmx-value id="linkcode" dmx-bind:value="'<%= $_PARAM.linkedcode %>'"></dmx-value>

Alternative you could just set a static value like:

<dmx-value id="linkcode" value="<%= $_PARAM.linkedcode %>"></dmx-value>
4 Likes

Ah yes! Missed the quotes.

THIS is an Important Page to read, NODERS :mask: :sweat_smile:

I’m Bookmarking.

It would be GREAT if a lot of these isolated SOLVED forum posts could be put into a couple of Video tutorials. These are real world problems with solutions particular to working in the Wappler & NODE.js environment, which is the Main Push now by Wappler management.

The funny thing is that this is not even a Wappler thing but it is actually part of how express and ejs templates work. Knowing this expands the knowledge center to a web search engine instead of limiting it to Wappler forum.

An “Under the hood” section in https://docsdev.wappler.io could be interesting so people know that they can expand their knowledge of Wappler by learning the underlying tech which it is built on if that is what they want to do.

4 Likes

So…to get the route params, I always need to create a variable to store its value?

The question is: where do you want to get the route param? server side or client side?

And it also depends whether you’re using layouts and content pages or partials.

If it’s client side then define query param on the app within the layout.
If it’s server side… well I haven’t figured it out yet…

1 Like

This works!!! it is resolved!!

{{query.token}}

As Alexandre told you, just put query.name_of_variable and it works :slight_smile: