Query with multiple params given' multiple results

Well, I have a Wix Database with a lot of products.

It’s like ProductName, Segment, Industry :
Product1, Plastic, Construction // Product2, Organic, FoodIndustry // …

So… I have some “solutions” links, like “For FoodIndustry, with organic components you need this products”, and if you click in the link, you will see a table with a list of Products that match that conditions.

Well, at this time I have a Button with a OnClick event, and https//www.blablabla/page?product=Product2,Product3 etc.

So, in the Product page I use wixLocation.query, to obtain “producto = Product2,Product3”, and then I use split to create an array with the name of the products that the table must show.

Here is the problem… For some reason that I don’t know, I get two Products from Query (in url), : [Product1, Product2], then I pass those two elements in the array “separated”, but in the table only appears Product1, obviously the query only returns ONE results, but I don’t know why.

I want to send TWO products in the URL, and show TWO products in the table.

I’m going crazy!

I’ll appreciate the help.
Thank you!

Here is the code from the web that receive the parameters.

import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;

$w.onReady(() => {

let queryParam = wixLocation.query;
let separated = queryParam;
separated = separated.product;
separated = separated.split(“,”);

let filters = wixData.query(“Products”)
.hasSome(“title”, separated)
.find()
.then((results) => {
console.log(results.items);
$w(‘#table1’).rows = results.items;
})
. catch ((error) => {
let errorMsg = error.message;
let code = error.code;
});
})

I am running into a similar issue. But the way I send a list of parameters is slightly different. I am using multiple query parameters instead. So, for example, my URL query looks like this: “?foo=asd&foo=qwe”.

My code on the receiving end works because when I test for URLs that I type manually, it all works and I can get the list of parameters by doing the following:

let foos = wixLocation.query.foo
if (!Array.isArray(foos)){
    foos = foos.split(",");
}

That works well and I am able to get the list of parameters when I type the url manually.

My problem is on the sending side. When I do this:

wixLocation.to("/stores/products?foo=asd&foo=qwe");

The page actually gets redirected to “/stores/products?foo=asd”. Somehow, it seems the “wixLocation.to” method is deleting some of my query parameters.

Did you ever find a solution to your problem?

I just found out that it suffices to use “,” as a separator when creating the query parameter string. So, the following fixes my issue:


wixLocation.to("/stores/products?foo=asd,qwe");