Create nested array with json object with form-data

Hello there.

For a couple of days now, I try to create a nested array and have an object inside that array where I can set text key/value pairs while simultaneously uploading files (hence form-data).

In the end, I want the following object: {media: [{media: file, type: video}, {media: file1, type: photo]}

The way I tried to achieve this, and which I still think should be the way to go:


but this doesnt end up as an array.

Maybe you are missing some JavaScript basics.

You create an array like this:

const a = [];

Add add items like this:

a.push({media: "file", type: "video"})