I'm stuck with passing params to my API call. There is API call for getting companies in search. And some filters which I pass as params to axios get query.
Problem with income param which looks like this income: ["$100K - $124K"]
On API this call looks like this:
companies?page=1&limit=12&income=%24100K%20-%20%24124K
But in my case:
companies?page=1&limit=12&income=[]=$100K+-+$124K
and I'm getting wrong response with that.
Here code of my API call:
export const getCompanies = ({page, limit, query, ...rest}: {page: number, limit: number, query?: string}): Promise<AxiosResponse<{items: Company[], meta: Meta}>> => {
return http.get('companies', {
params: {
page,
limit,
q: query,
...rest
}
})
}
income param comes with ...rest (and this is actually correct because every other filter-param works well except that one)
By the way, I wouldn't mind if you rate my idea of passing params as ...rest (I'm not confident about that)