Skip to content
Discussion options

You must be logged in to vote

Hello @zdllucky

I have 3 solutions for you

Encode properly

When you send arrays in query parameters, they have to be distinguishable from regular strings.
Comma separation does not do that, it's not a conventional way for encoding arrays.
Though there are many of them, the most common one looks a bit more weird, but it works (I checked it):

curl -X 'GET' \
  'http://localhost:3950/api?states[]=created&states[]=removed&states[]=changed' \
  -H 'accept: application/json'

So you have to repeat states[] with brackets for multiple elements — this is for express 4.
⚠️ In express 5 they changed "extended" query parser to "simple" and states must be repeated without brackets.
This will be made co…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by RobinTail
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
good first issue Good for newcomers
2 participants