1
I did a lot of research on how to do this and I got no response. Here’s the situation: I have a listById method that needs to get the id that comes in the URL through the form. It turns out that when I submit the form, it forwards to the URL that is in the action + ? id=#o_que_o_usuário_digitou#. Hence my route manager cannot handle this.
HTML:
<form class="container" action="/listById/" method="GET">
<input class="form-control" type="text" name="id" id="id">
<button id="btn-search" class="btn btn-primary" type="submit">Search</button>
</form>
Route manager:
app.get('/listById/:id', controlcontact.listById);
METHOD called on the route:
contact.listById = (req,res)=>{
request.get(externalApi+req.params.id,
(error, response, body) => {
res.render('listById',{
contact: JSON.parse(body)
})
});
}
Example: if the input is typed "12345", Submit forwards to "/listById/? id=12345" I wanted to solve this only using HTML, without having to create javascript function.