I want to loop throught a request
for (let i = 0; i < req.body.email.length; i++) {
... = req.body.email[i];
... = req.body.role[i];
..}
The result should look like this:
{
users: [
{ email: 'a@gmx.de', role: 'read' },
{ email: 'b@gmx.de', role: 'admin' },
{ email: 'c@gmx.de', role: 'read' },
...
]
}
I tried really long but just cant get it in this format in a simple and clean way. Whats the best and cleanest way to do this?