I want to add multiple parameters with the same name to a request URL. I'm using Angular's $http.
The URL should look like this:
http://myBaseUrl?name1=value1&name1=value2...
I know that it is possible to make something like this when I set the values as an array:
http://myBaseUrl?name1=value1,value2...
But it has to be like the first one.
If you're using HttpClient you can use HttpParams for this.
let params = new HttpParams();
// Assign parameters
params = params.append('firstParameter', 'valueOne');
params = params.append('firstParameter', 'valueTwo');
// Get request
this.http.get(`http://example.com`, { params }).subscribe();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With