You are not fully utilizing the capabilities of typescript
in this scenario, which is why you are encountering difficulty accessing the id
property. It's important to define the type of arguments, responses, invocations, and returns whenever possible.
In your specific situation, you neglected to specify how angular should handle the response from this post
request. Essentially, you need to determine what type of data will be received. To address this, consider using a typescript type assertion
, like so:
Keep in mind that the properties and types I included in the post request are just examples.
this.httpClient.post<{
prop1: string;
prop2: boolean;
id: number
}>(this.path + 'cities/add', city)