How to handle dynamic values of query params #14764
-
Hi all, I am developing a page which has different filters, upon selecting any filter, query params need to be updated. For this, I am using the following code. Router.replace( The issue I am facing is, I am getting query params in the URL even though the value is null like Is there any way to tell next router to not use particular param if the value is null. (like in Axios post)? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You could use this for your query object: query: {
...(filteredArray.length && {l: filteredArray}),
...(departmentFilters.length && {d: departmentFilters}),
...(keyword && {q: keyword})
}, that will conditionally add the filter properties to the query object |
Beta Was this translation helpful? Give feedback.
You could use this for your query object:
that will conditionally add the filter properties to the query object