Reputation: 2025
I have a weak dependency error in typescript.
Type Headers has no properties in common with type..
I am trying to send post and delete request to another api for 2 different methods. my ts code in service have 2 different method, the first one "addcustomer" is working without problem but second "deletecustomer" is not,
addcustomer(customer: string, disable: boolean): Observable<customer> {
const newAddcustomerModel = {
customer: customer, disable: disable
} as AddcustomerModel;
return this.http.post<customer>(`/api/admin/add-customers`, newAddcustomerModel);
}
deletecustomer(id: number): Observable<customer> {
const newcustomerModel = {
id: id
} as DeletecustomerModel;
return this.http.delete<customer>(`/api/admin/delete-customers`, newcustomerModel)
}
and models for them
export interface AddCustomerModel {
customer: string;
disable: boolean;
}
and for second one is:
export interface DeleteCustomerModel {
id: number;
}
The error is on newcustomerModel which is in deletecustomer() method at last line.
Upvotes: 2
Views: 3835
Reputation: 41445
Create HttpHeaders
instance to allocate the headers
let newcustomerModel = new HttpHeaders({
id: id
} )
this.http.delete<customer>(`/api/admin/delete-customers`, {headers: newcustomerModel })
Upvotes: 2