There are many Q&As on how to append the uploaded files to a FormData before submitting but none is about what if the POST/PUT request payload has to be a nested object with the uploaded files as one part of it.
Here is my payload format:
{
operator: // some String
documentTitle: // some String
time: // some Number
date: // some Date
sections: [
{
section_id: 0,
sortOrder: 0,
title: "",
subsections: [
{
subsection_id: 0,
files: []
},
{
subsection_id: 1,
files: []
},
]
},
{
section_id: 1,
sortOrder: 1,
title: "",
subsections: [
{
subsection_id: 0,
files: []
},
{
subsection_id: 1,
files: []
},
]
},
];
}
The files within the subsections should be filled with uploaded files and I still get empty files in my request payload even though I appended them to a FormData