1

I try use in Angular http.get with params :

i put to get (data)

getAllVM(data) {
        console.log('data', data, 'params' ,(getParamString(data)));
        return this.http.get(environment.apiEndpoint + '/vendorMachine', {params: {filters: data}});
}

results consol.log =>

data {status: Array(0), groups: Array(1)}groups: [2]status: []__proto__: Object params ?status=&groups=2

in header i send:

?filters=%5Bobject%20Object%5D

how can i change this to correct?

Arek Szumacher
  • 348
  • 1
  • 4
  • 14
  • have a look at this https://stackoverflow.com/questions/44280303/angular-http-get-with-parameter/44282037 – Abdul Basit Feb 14 '19 at 09:18
  • Possible duplicate of [How to pass url arguments (query string) to a HTTP request on Angular?](https://stackoverflow.com/questions/34475523/how-to-pass-url-arguments-query-string-to-a-http-request-on-angular) – Abdul Basit Feb 14 '19 at 09:36

2 Answers2

2

Add get parameters as below to your http get request.

getAllVM(data) {

    const params = new HttpParams().set('filters', JSON.stringify(data));
    return this.http.get(environment.apiEndpoint + '/vendorMachine', { params: params });
}
Sudarshana Dayananda
  • 5,165
  • 2
  • 23
  • 45
1

Angular does not offer filters as option.

https://angular.io/api/common/http/HttpClient

use this instead:

this.http.get($(environment.apiEndpoint)/vendorMachine?filters=${data})

if data is a json use JSON.stringfy(data)

G.Vitelli
  • 1,229
  • 9
  • 18