This is how I need to send the request.
localhost:8080/api/user?id=53380&name=raj&start=1&rows=5
where id=53380&name=raj is one object.
Tried setting the param and send like below.
let params: URLSearchParams = this.objToSearchParams(this.search); // this.search = {id: 53380, name: raj}
params.set("start", 1);
params.set("rows", 5)
return this._http.get('/api/user', {params: params})
.map(response => response['result'])
.catch(this.handleError);
objToSearchParams(obj): URLSearchParams{
let params: URLSearchParams = new URLSearchParams();
for (var key in obj) {
if (obj.hasOwnProperty(key))
params.set(key, obj[key]);
}
return params;
}
This doesn't sends any request this is the API call after executing this code
localhost:8080/api/user
there is no params send. How can I achieve this ? Do I need to manually convert one by one ?