My angular component:
const p: Product = this.products.find((d) => d === event.item.data);
p.name = 'foo';
My angular service is:
updateProduct(product: Product): Observable<CommonResult> {
return this.http.put<CommonResult>(this.configService.getApiUri() + '/products/' + product.productId, product);
}
My Product model:
export class Product {
id: number;
name: string;
category: string = null;
}
I want:
{
id: 1
name: "foo",
category: null
}
but I have:
{
id: 1
name: "foo"
}
I do not access to my backend code (I can not change backend code). How to patch my Frontend code to fix my issue?
I patch my update because my GET do not return category: null
{...new Product(), ...product}
full code:
updateProduct(product: Product): Observable<CommonResult> {
return this.http.put<CommonResult>(this.configService.getApiUri() + '/products/' + product.productId, {...new Product(), ...product});
}