Forum Discussion
Yes, indexOf() returns the index not the value.
Using your example data in a json generator, and a mapper with this expression:
$items.map(value => value.extend({'Data_Index':$items.indexOf(value)}))
you will see that the original map uses extend to add the index of each element to a new field ‘Data_Index’ in each value in the list.
Also, for the below screesnshot, i want to take the index as to how many responses returned. Since this is at the root level i tried $.map(value => value.extend({‘Batch_Index’:$.indexOf(value)})), but it is giving me an an error as
“Map type does not have a method named: map, found in: …dexOf(value)})). Perhaps you meant: mapKeys, mapValues”"
If you believe this is an error in the Snap, submit a ticket to SnapLogic Support at support@snaplogic.com.