HI all, i wanna to check there are no duplicate values in the array of objects

function checkIfArrayIsUnique(array) {
return array.length === new Set(array).size;
}

pm.test(‘Check is Ids are unique’, () => {
let ids =
_.each(pm.response.json().contantInfo, (item) => {
ids.push(item.id)
})

pm.expect(checkIfArrayIsUnique(ids), ids).to.be.true

})

I’m assuming you got that function from here.

Based on that function, the following seems to work.

const response = pm.response.json().contantInfo; // parse straight to the array

let IDs = response.map(obj => obj.id); // create a new flat array of just the IDs

function hasDuplicates(array) {
    return (new Set(array)).size !== array.length;
}

pm.test("Check IDs are unique", () => {
    pm.expect(hasDuplicates(IDs)).to.equal(false);
    // or pm.expect(hasDuplicates(IDs)).to.be.false;
});