Suppose I have the class
export class DummyClass {
name: string;
value: number = 10;
}
So a class that holds only name and value with a default value of 10.
If I now want to get data from the server and I initiate my call.
this.httpClient.post<DummyClass>(...)
And the json response is
{
"name": "john doe"
}
Then my class also looks like this. This implies I have complete lost my property value with its default value as wel. And this was the whole point of my default value -> such that the server does not need to send default values.
How can I correctly map the json response to a model and not lose default values.