How to get unique values from csv using shared array

Facing issues like variable name not defined while calling the unique value from csv file as variable in Http request

How variable been defined:

const users = new SharedArray(“users”, function () {
return papaparse.parse(open(‘./data.csv’), { header: true }).data;
});

export default function () {

let user = users[exec.scenario.iterationInTest % users.length];
console.log(‘user:’, user.username);
}

HTTP Request:

// LoginPage
response = http.post(
https://xxxx-yyyy.com/login’,
{
Email: user.username,
Password: ‘XXXX’,
NewAuth: ‘true’,
}

Error encountered ERRO[0011] ReferenceError: user is not defined

Thanks

Hi @sattivasudevan

It is because let user = ... is inside the default function() and the Email: user.username is outside of the function.

@bandorko Thanks for your response. Is their a recommended way to declare the variables so that it can be accessed without performance issues . 2. How we can manage the recycle at end of the file while accessing the unique values. Is it taken care by shared array. If you can share the skeletal code it would be much easy for us to start implementing it.