I have got a params variable in Angular service which is of type HttpParams.
When I do
params.set('sortby', sortby.toString());
or
params.set('top', top.toString());
both of this are working and getting added to params variable and passing on to the API.
However the issue is when I have a route param defined as 'query' in the API. I failed to understand why my code,
params.set('query', query.toString());
not working at all. It just don't get added to the params list. I assume it is something to do with the name 'query'. Updating API is not a choice at this moment.
Is there a way I could make 'query' work?
API Call :
Try updating directly to the request from chrome console. Even then I could not find the query param.
EDIT : newParams()
That is returning the HttpParams with a correct codec
protected newParams(): HttpParams {
return new HttpParams({
encoder: PARAMETER_CODEC
});
}
And Encoder is ,
class ParameterCodec implements HttpParameterCodec {
encodeKey(key: string): string {
return encodeURIComponent(key);
}
encodeValue(value: string): string {
return encodeURIComponent(value);
}
decodeKey(key: string): string {
return decodeURIComponent(key);
}
decodeValue(value: string): string {
return decodeURIComponent(value);
}
}
const PARAMETER_CODEC = new ParameterCodec();


params = params.set('query', "alo");not justparams.set('query', "alo");?let params = new HttpParams().set('query', 'myname')works fine for meparams.queryactually exists? Try setting the query param with some random string, and see if that works