I want to have the following json example:
{
attachments: {
file: [
{ name: 'pic1.jpg' },
{ name: 'pic2.png' }
],
username: 'Test',
age: 1
}
}
is this possible in formdata?
OK, i figured it out. Just pass another key before array key... like:
fd = new FormData();
const files = [{...}, {...}, ...]
files.map(file => {
fd.append("attachments[] file[]", file.name)
});
fd.append("attachments[] name", 'Test')
fd.append("attachments[] age", 1)