1
I’m trying to pass a map on an api that should print videos on a website. When he finishes making the map he is not taking the videos of the next category and populating the object. I created the following JSON for testing:
[
    {
        "id": 1,
        "slug": "futebol",
        "name": "Futebol",
        "videos": [
            {
                "id": 1,
                "link": "https://www.youtube.com/watch?v=CWWOW7T82Hw",
                "title": "Dribles mais humilhates da historia",
                "index": false,
                "image": "no-img.jpg",
                "categories": [
                    {
                        "slug": "futebol",
                        "name": "Futebol"
                    }
                ]
            },
            {
                "id": 2,
                "link": "https://www.youtube.com/watch?v=vOqfupUXkkY",
                "title": "Os movimentos mais bonitos do futebol",
                "index": false,
                "image": "no-img.jpg",
                "categories": [
                    {
                        "slug": "futebol",
                        "name": "Futebol"
                    }
                ]
            }
        ]
    },
    {
        "id": 29,
        "slug": "cachorro",
        "name": "Cachorro",
        "videos": [
            {
                "id": 3,
                "link": "https://www.youtube.com/watch?v=S-gWb3sV9mY",
                "title": "Videos engraçados de cachorro",
                "index": false,
                "image": "no-img.jpg",
                "categories": [
                    {
                        "slug": "cachorro",
                        "name": "Cachorro"
                    }
                ]
            },
            {
                "id": 4,
                "link": "https://www.youtube.com/watch?v=Nu5K2IRrsiY",
                "title": "Videos engraçados de cachorro 2",
                "index": false,
                "image": "no-img.jpg",
                "categories": [
                    {
                        "slug": "cachorro",
                        "name": "Cachorro"
                    }
                ]
            }
        ]
    }
]
And I’m making the following map on the object:
const [videosObject] = videoCategories.map((item) =>
      item.videos.map((obj) => obj),
)
I understood that by unstructuring the object using [videosObject, videosObject2] I can take all the data of the two objects of the array but I wanted to put the 4 video objects that are in the 2 video arrays in only one object of type array with this 4 objects and print this data and I’m not sure which resource I use.
Your question was not clear, what was the desired result at the end?
– LeAndrade
The end result I expect is only the 4 video objects that are inside the video arrays
– Antonio Carlos Araújo