Is a specific product in the basket?

Finding if a given product was purchased and thus in the basketContents is best done using the simpleBasketObj.

The simpleBasketObj contains an entry for each basket (usually only one but different setups can yield multiple baskets). Each basket entry contains an array with one entry per item placed in the basket. The UPC field of this entry gives us the unique product code of the item (this is the client supplied UPC usually found on the shelf setup spreadsheets).

So the code below simply loops the 2 arrays using the normal JS Array.some

We then use the JS Array.includes to test the items UPC with the supplied search list in the targetList array.

// targetList is an array of UPCs to check for in baskets

let result = simpleBasketObj.some(sb =>
  sb.basket.some(item => targetList.includes(item.UPC))
)
var r = await syrup.fetchRespondentData({
  projectID: '8fcbb2dc-8093-40d7-6c41-88ecccdcb2aa',
  pageID: 'b8b70dca-a5b8-4a1a-4a8f-f60254fea95c',
  respondentID: 'HNTEST12',
})
let targetList = ['8431876054019']
let simpleBasket = r.questions().simpleBasketObj()
let result = simpleBasket.some(sb =>
  sb.basket.some(item => targetList.includes(item.UPC))
)
console.log('simpleBasket: ', simpleBasket)
console.log('targetList: ', targetList)
console.log('Result: ', result)

Click Execute above and check the simpleBasket output and you will see we do in fact have a product with a UPC = 8431876054019 which is also the targetList