I am trying create json request body. where most of the fields are optional. I want to keep them if the value is defined for them or remove if they are undefined.
let payalod = data {
id: 1,
type: "sale"
name: undefined // optional
}
I want to keep the name property optional. means if the value is undefied we can remove if before sending the request. if guess it can be achived with a ? sing (optional chaining). but not able to get the syntax.
can anyone help me with optional chaining approach TIA.