Created a database of products and I want to be able to search for a product, then filter by category. I would also like to be able to filter from all of the products if there is no search. Right now, the search and filter are working independently but if I try to filter after searching, it replaces the search query and just applies the filter.
For example, I could search "abc" and the URL would be http://localhost:1337/search/?search_string=abc. If I filter by "category" after the search, the url would be http://localhost:1337/category. I would like to get a url of http://localhost:1337/search/?search_string=abc/category if this is possible.
Right now I have one ejs file, since the format of the site is pretty much the same for all pages. The only difference is that my app.get methods in my js file filter the products by the search or category, then render only the valid ones to the ejs file. My homepage simply displays all of the products.
Please let me know how I could fix this problem and append to the end of my search query.
edit:
Right now my ejs categories are hyperlinks that append to the end of the url.
<a href="/category">Category</a>
This works for the home page, but the search query part gets eliminated and the url turns into http://localhost:1337/category even if the current URL contains a search query.