Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Filter" parameter as object or array #42

Open
somenugget opened this issue Jan 31, 2018 · 3 comments
Open

"Filter" parameter as object or array #42

somenugget opened this issue Jan 31, 2018 · 3 comments

Comments

@somenugget
Copy link

Hello)

Is it possible to create a request with like below using redux-bees?
http://localhost:3000/cities?filter[country_id]=1

I had tried
api.getCities({ filter: { country_id: countryId } })
but got only
http://localhost:3000/cities?filter=%5Bobject%20Object%5D

@planetcrypton
Copy link

Same here :)

@planetcrypton
Copy link

Found a workaround, though:

perform({ "filter[slug]": props.match.params.model, "filter[brand]": props.match.params.brand})

Seems like all unknown properties will be passed at querystring parameters...

@MrLeebo
Copy link

MrLeebo commented Sep 7, 2018

When I have GET requests with complex parameters, I like to use method overrides, e.g. POST /cities?_method=GET where _method=GET is a hint to the API's router to route the request as a GET even though it's technically a POST. Then you have the full post body to work with. Useful on parameters for server-rendered data grids like...

{ 
  page: 1, 
  pageSize: 10, 
  filtered: [{ operation: 'startsWith', id: 'attributes.name', value: 'Sam' }], 
  sorted: [{ id: 'attributes.age', descending: false }, { id: 'attributes.name', descending: true }] 
}

...without blowing up your URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants