I have a input (search bar) in ejs file and the other in another file. im using expressjs and nodejs. its possible?
The first file:
<form action="/profiles/username" method="GET">
<input type="text" placeholder="Search user..." name="username">
<button type="submit" class="btn btn-outline-success"><i class="fas fa-search</i></button>
</form>
And the second file
<h3 class="mt-5">You searched for <%= req.params.username %></h3>
Route file:
router.get('/profiles/:username', async (req, res) => {
const allProfiles = await User.find({username: req.params.username})
if (allProfiles){
console.log(allProfiles)
}
res.render('profiles')})