How do I extract the array values in the collection variable?
I used this script to capture the values I would like to store in the collection variable array:
pm.test("Armazenando valores de response", function () {
//criando variável na collection
let responses = pm.collectionVariables.get('infoCount')
if(responses) {
responses = JSON.parse(responses);
} else {
responses = []
}
//setando valores na variável
responses.push(pm.response.json().info.count);
pm.collectionVariables.set('infoCount', JSON.stringify(responses));
//visualizando o primeiro item do array response.message
console.log(responseVerifyUser)
});
The value in the collection variable:
I tried extracting the values as follows:
let responseTest = pm.collectionVariables.get('infoCount')
console.log(responseTest)
The result then was this
however when I try to get the value of the index [0] the result looks like this
console.log(responseTest[0])
[1] = “8”
[2] = “2”
[3] = “6”
[4] = “]”
How then do I extract from the index array [0] = 826, [1] = 827 … from the collection variable? (and not in this “broken” way that is coming)