await axios.post<EventType[] | { errorMessage: string }>(urlApiCmdPublic, cmd) only works for non-error responses.
Fetch in comparison does not have any types at all
Not exactly true, you get aResponse which makes sense. And then you can convert to json and do validation i.e using zod schema.parse(await response.json()) to get a concrete type. Which is a much better approach than what axios offers
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
await axios.post<EventType[] | { errorMessage: string }>(urlApiCmdPublic, cmd)only works for non-error responses.Not exactly true, you get a
Responsewhich makes sense. And then you can convert to json and do validation i.e using zodschema.parse(await response.json())to get a concrete type. Which is a much better approach than what axios offers