I am looking to create an API body for use in JavaScript fetch. The array contains around twenty items and I need to iterate through it using a loop.
Here is an example of my array of objects:
[
{
name:"x",lname:"y"
},
{
name:"x2",lname:"y2"
},
]
This is the desired output structure:
{
"0":{
"name":"x",
"lname":"y"
},
"1":{
"name":"x2",
"lname":"y2"
},
}
This is how it appears in Postman when sent as the body:
https://i.sstatic.net/k63lI.png
Any suggestions or assistance would be greatly appreciated.