I am trying to use pro-gallery library in my project and it accepts an array of image like this :
const items = [
{
// Image item:
itemId: "sample-id",
mediaUrl: "https://i.picsum.photos/id/674/200/300.jpg?hmac=kS3VQkm7AuZdYJGUABZGmnNj_3KtZ6Twgb5Qb9ITssY",
metaData: {
type: "image",
height: 10,
width: 100,
title: "sample-title",
description: "sample-description",
},
},
...
]
But my own array of items looks like this, how would you do to extract interesting fields and recreate a new array ?
"products": [
{
"_id": "618e2787d193ae4a3068cae5",
"name": "Photo",
"category": "cuba",
"image": "https://someimage.com/dqve1.jpg",
"price": 20,
"countInStock": 12,
"brand": "John Doe",
"description": "Description example...",
"seller": "618aeab0f82f5854ec925a5f",
},
...
]