I want to send an HTTP request with parameters via a query
Example:
URL: https://api/endpoint?d=1&value=2
I want to send an HTTP request with parameters via a query
Example:
URL: https://api/endpoint?d=1&value=2
To add params for your URL, you need to create the correct options, for example:
const options = { params: new HttpParams().set('value1', '1').set('value2', '2') };
return this.http.get(`${APP_BASE_URL}/endpoint`, options);
Before is an example, you can create a petition with params of many ways.
Check the documentation here
You can create an object and pass it as 2nd parameter in get method.
const url="example.com/data";
const parameters = {
'value1': 1,
'value2': 2
};
return this.httpClient.get(url, {
params: parameters
})
This will create your url like below:-
URL: https://api/endpoint?value1=1&value2=2