Search code examples
javascriptangularapiangular-httpclientangular10

How to pass multiple values to a parameter in a GET API in angular 9+ using http client


I'm getting an array of Id's like below:-

id=[1,2,3,4]

How to dynamically pass those value from array id to a parameter of a API request like this in angular:-

this.http.get(`/api/request?num=1,2,3,4`);

Solution

  • You can provide the params like this:

    const num = [1,2,3,4]
    this.http.get(`/api/request`, {params: {num}});