node.js - Getting dynamic routing input from HTML -


i using ejs templating language .

<main class="content">     <% documents.foreach(function(documentobject) { %>     <h1><a href="/showprofile/:username"><%= documentobject.username %></a> solved </h1>     <h2><%= documentobject.problem_id %>. <%= documentobject._statement %> in       <%= documentobject.time %>  seconds on       <%= documentobject.date_added %> . </h2>     <% }) %>   </main> 

i using dynamic route /showprofile/:username redirection . need make hyperlink in such way such value of documentobject.username gets passed parameter :username . how can ?

you use ejs function render username in href attribute instead of :username:

<h1><a href="/showprofile/<%= documentobject.username %>"><%= documentobject.username %></a> solved </h1> 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -