Passing array into URLSearchParams while consuming http call for get request

Madhu Ranjan picture Madhu Ranjan · Aug 5, 2016 · Viewed 23.4k times · Source

Going through the Angular documentation for URLSearchParams, I dint find any documentation on passing array as an parameter.

Can anybody help with that?

Answer

Thierry Templier picture Thierry Templier · Aug 5, 2016

In fact, you can't pass an array directly but you can use several times the append method:

let params = new URLSearchParams();
params.append('arrayparams', 'val1');
params.append('arrayparams', 'val2');
params.append('arrayparams', 'val3');