Code:
toFormData(): FormData {
const service = new FormDataService(
this,
(key: string, value: any, formData: FormData) => {
if (key === 'files' && this.files !== undefined) {
let i = 0
for (const f of this.files) {
if (f.fileObject !== undefined) {
formData.append(`files[${i}][file]`, f.fileObject)
}
if (f.id !== undefined) {
formData.append(`files[${i}][id]`, f.id)
}
i = i + 1
}
}
formData.append(key, value)
}
)
service.setDateType(['carry_transfer_date', 'started_at', 'ended_at'])
service.setExclude(['toFormData', 'created_at', 'updated_at'])
return service.execute()
I wanna put the null check on this code because formData convert everything on string so i am having a null string like this "null" when the input is empty so i wanna put the null check on the formData.append(key, value). if anyone can help me i would love it thank you