Hello sorry for noob question,
I'd like to ask about how could I get query parameters in array
for example I have this endpoint,
I want to get books that have genre romance or comedy from this route
http://localhost:3001/books?genre=romance&genre=comedy
I'm using this code
Copy code
val genre = call.request.queryParameters["genre"]
but only return the first genre which is
romance
m
molikuner
08/14/2019, 5:36 PM
I don't have a answer to your question, but why do you use the query parameter multiple times? You could define it as commar separated list:
http://localhost:3001/books?genre=romance,comedy
This would be easy to use and is used in most publicly available websites.
s
Sergey Bondari
08/14/2019, 5:42 PM
You should use array notation, genre[]=romance&genre[]=comedy
a
Alexander
08/14/2019, 6:50 PM
Copy code
val genres = call.request.queryParameters.getAll("genre")