I want to generate a query string for my advanced filter. My object looks as follows:
{
searchValue: {
firstName: "John",
lastName: "Doe",
postalCode: "3130",
city: "New York"
},
page: 1
}
I'm using the querystring library to try and format my desired string.
export function updateAdvancedSearchQueryString<T>(props: RouteComponentProps, newValues: T) {
props.history.push({
pathname: props.location.pathname,
search: queryString.stringify(newValues)
});
}
The output I want to achieve:
/trainers?page=1&searchValue=firstName=John&lastName=Doe&postalCode=3130&city=New_York
The output I'm currently getting with this:
/trainers?page=1&searchValue=%5Bobject%20Object%5D
How can I generate my desired querystring from the nested object?