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?

2

2 Answers 2

3

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 });
}
Sign up to request clarification or add additional context in comments.

Comments

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)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.