Answer the question
In order to leave comments, you need to log in
How to correctly pass get-parameters and conveniently work with Url in js?
Hey!
There is a typical online store with product filtering by different parameters/criteria.
I started doing something like this:
site.ru/cat/?param=102,105,204&view=1&sort=asd
But when changing (on/off) some parameter, you need to parse the URL, parse the parameters (comma-separated), rebuild the URL, which seems to me pretty boring job.
Now I came across that some people pass parameters in an array:
site.ru/cat/?param[]=102¶m[]=105¶m[]=204&view=1&sort=asd
Which approach is correct? Advise how similar tasks on the client are correctly solved?
PS I found js libraries for URL parsing, for example https://github.com/Mikhus/jsurl
But they don't work with arrays (param[] - such parameter names are not supported).
Thank you!
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question