Reputation: 14142
I have the following function that shows the following error in the TSlinting - Can anyone suggest why I am getting this error?
Argument of type 'string[]' is not assignable to type parameter of type 'string'
cancelEvent(id): any {
let pages: Array<string> = [];
let requestParams = new HttpParams().set('pages[]', pages);
}
Upvotes: 0
Views: 601
Reputation: 166
HttpParams().set can set only string values.However you can do something like below
let pages: Array<string> = [];
let requestParams = new HttpParams().set('pages[]', pages.join(','));
and use split() to get values back into array.
Upvotes: 1
Reputation: 222532
You cannot set String[] in headers, it should be of type string,
The definition of the set method is:
set(param: string, value: string): HttpParams;
so value can be only a string
.
let requestParams = new HttpParams().set('pages[]', pages); // it should be string
Upvotes: 3