Hello sorry for noob question, I'd like to ask abo...
# ktor
d
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
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
You should use array notation, genre[]=romance&genre[]=comedy
a
Copy code
val genres = call.request.queryParameters.getAll("genre")
­čĹŹ 1
d
oh nice, thank you