Beacon24 / v0

4 stars 2 forks source link

Unsuccesful `GET` request under `explore` route/controller, `explore.search` yields empty `req.params` #6

Closed Beacon24 closed 2 years ago

Beacon24 commented 2 years ago

I am trying to set up a keyword search for all users, initiatives, and groups in the database. I am doing this through a route named explore. explore.search (defined in the explore.js controller file) is triggered by a submitted form GET request in views/explore/index, but when I console.log(req.params) I only get {}.

I am also uncertain as to how I can convert the input from the explore index.ejs form into an array of 'keywords' to feed into db.<collectionName>.find({}).

This is my first time trying to execute a find() command through an input search, so I'm sure I have made many mistakes.

UPDATE: I am wondering if my form submission is properly routed, I tried a console.log('test') to see if the explore.search function (in the controller file) was even triggering, and did not get the proper print-out when I submitted the form.

Beacon24 commented 2 years ago

Fixed. Problem was with routing, I had two GET requests going to the same /explore route. I added a /explore/search route and changed the search form action to /explore/search, and now the request goes through.