If i validate two API ? with respect to Object and values if the both API's are objects and values are different i want those objects and values to be printed in console

Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.

Hereā€™s an outline with best practices for making your inquiry.

My question:If i validate two API ? with respect to Object and values if the both APIā€™s are objects and values are different i want those objects and values to be printed in console

Details (like screenshots): In first Api tests i wrote this

const response = pm.response.json();
pm.globals.set(ā€œfirstresponseā€, response);

How I found the problem:in second API test i used compare by writing in test tab

pm.test(ā€˜Response is idential to other responseā€™, function() {
var responsepage2=pm.response.json();

const responsepage1=pm.globals.get("firstresponse");
pm.expect(responsepage2).to.eql(responsepage1);

});
but unable print the objects and values which are different

Iā€™ve already tried:

Producing the DIFF on an array\object is not straight forward.

Itā€™s all according to how complex the object is.

The following is a really basic example but wonā€™t work for complex objects (arrays within arrays etc).

var array1 = [1, 2, 3, 4, 8, 5, 6, 7];
console.log(array1);
var array2 = [6, 5, 4, 3, 2, 1];
console.log(array2);

if (array2.length >= array1.length) {
    var difference = array2.filter(n=>!array1.includes(n))
} else {
    var difference = array1.filter(n=>!array2.includes(n))
}

console.log(difference);

This is complex, and to do this properly for complex JSON\Objects, you need some additional libraries\helpers which arenā€™t available in Postman unless you want to write a ton of JavaScript code.