-5
[
    {
        "data": {
            "user": {
                "id": 9,
                "email": "abcd@example.com",
            },
            "country": "USA",
        },
    },
    {
        "data": {
            "user": {
                "id": 8,
                "email": "efgh@example.com",
            },
            "country": "USA",
        },
    },
    {
        "data": {
            "user": {
                "id": 9,
                "email": "abcd@example.com",
            },
            "country": "USA",
        },
    }
]

I am working on a js project and I need help here. How to get only unique data from above? i.e. I want to remove the duplicate data.user.id from the original object and derive a new object from it. i.e. I want only the below values from above object

[
    {
        "data": {
            "user": {
                "id": 9,
                "email": "abcd@example.com",
            },
            "country": "USA",
        },
    },
    {
        "data": {
            "user": {
                "id": 8,
                "email": "efgh@example.com",
            },
            "country": "USA",
        },
    }
]
Benk I
  • 159
  • 7

0 Answers0