Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to add the same query parameter with different values multiple times using JavaScript ?

We have the following requirement wherein I want to set a specific query parameter "type" 3 times to the request object as shown in the example below:

"country=India&type=siteid:1&format=json&fullText=true&type=currencytypename:text&type=languagetypecode:promo" 

I used context.setVariable API to set the values for type 3 times as shown below:

var type = "siteid:1";
context.setVariable("request.queryparam.type", type);
type = "currencytypename:text";
context.setVariable("request.queryparam.type", type);
type = "languagetypecode:promo";
context.setVariable("request.queryparam.type", type);

However, when I check the request, I see only "type=siteid:1" exists but "type=authoringtypecode:promo" and "type=assettypename:text" are not in the request.

Can someone please let me know if there's a way to add the same query parameter with different values, multiple times using JavaScript ?

0 1 2,697
1 REPLY 1