Angular: Argument of type 'number' is not assignable to parameter of type 'string'
10,651
Based on what you have provided I am guessing that your User_id
is an integer (number). Try adding toString()
to the end of the User_id
property.
let params =new URLSearchParams();
params.set('User_id',t.User_id.toString());
params.set('complete', t.complete);
params.set('summary', t.summary);
params.set('description', t.description);
return this.http
.post(taskUrl, params)
.map(response =>
response.json());
If that's not it, then I may need a bit more information. Basically if this is truly where the error is originating from, you are probably trying to pass a number into the URLSearchParams
object as one of the values.
Related videos on Youtube
Author by
B.Burns
Updated on May 26, 2022Comments
-
B.Burns almost 2 years
I am a freshman in typescript.I wrote a table but it alarmed that
ERROR in E:/internship/angular-demo/ngdemo/src/app/_services/task.service.ts (24,27): Argument of type 'number' is not assignable to parameter of type 'string'.
I couldn't find the answer, so I've come to ask for a way to solve it.
Here is the code:
let params =new URLSearchParams(); params.set('User_id',t.User_id); params.set('complete', t.complete); params.set('summary', t.summary); params.set('description', t.description); return this.http .post(taskUrl, params) .map(response => response.json());