Posts

How to clear the search parameter that caused the error?

Image
0 Let's say I have a page that renders search results depending on the parameters in the URL like so: https://www.someurl.com/categories/somecategory?brands=brand1,brand2,brand3 Which results in the page showing only brand1, brand2, and brand3 listings. I also have a filter section on the side like so: [o] Brand 1 [ ] Brand 2 [o] Brand 3 [o] Brand 4 By ticking the items, the URL will get updated with the corresponding parameters. Basically, what happens is that I am fetching data from an API by passing the URL parameters as arguments, which then the server side endpoint takes in to return to me the matching data. Now the problem is that, if a user types into the URL an invalid parameter e.g. https://www.someurl.com/categories/somecategory?brands=somegibberish The server will return an error ...