Just confirming the proper way to handle situations like this.
My current setup involves using Vue front-end with Typescript, sending data to an API via axios.
I've defined reactive objects as follows:
const payload = reactive({
name: '',
religion: undefined as string | undefined,
gender: undefined as string | undefined
})
This is a basic example, but in cases where the religion and gender fields are not necessary unless explicitly provided when submitting the payload to the API, I have set them to default to undefined. This allows them to be filtered out before posting.
Am I handling this situation correctly?
Are there more efficient ways to approach this?