I have data that looks like this returning from an api
var data = {
"entities": [
{
"documentbody": Base64String,
"filename": "http-status-code-cheat-sheet1.png",
"filesize": 204326,
"mimetype": "image/png",
},
{
"documentbody": null,
"filename": "http-status-code-cheat-sheet2221.png",
"filesize": 204326,
"mimetype": "image/png",
}
]
}
I would like to create a new array that looks like this
var images = [
{ imgsrc:(documentBodyValue),imgDesc:(fileNameValue)},
{imgsrc:(documentBodyValue),imgDesc:(fileNameValue)}
]
I have tried using the map function let result = data.entities.map(a => a.filename);
but this only returns the values into a new array. How can i create a new array with different keys but values from the original array?