'Error calling a command based on the number of items within an array
I have the following problem: I want to call my service a number of times. This number of times must be based on the number of times in my array.
Below my step by step. Can someone help me?
Request
const createClaim = await request()
.post('/api/payloads')
.send(payload);
List with to my json request
const pays = async (entryMode) => {
const payload = {
card_number_id: '299ddaa0-316c-495e-89bc-65907aaab9a3',
brand: 'test',
affiliation_code: gwRegex(/^\d{7}$/),
card_number_head: gwRegex(/^\d{6}$/),
card_number_tail: gwRegex(/^\d{4}$/),
card_scheme: entryMode,
};
};
List with modes
const entryMode = [
'manual',
'manual_with_pass',
'magnetic_stripe',
'magnetic_stripe_full',
];
Within my test (describe > context > it, I want to create/call the number of times the "payload" const in a way that is created/called once for each item within the entryMode.
for (let i = 0; i < entryMode.length; i++) {
await payload(entryMode[i]);
}
That's the summary ... But I believe that the code has something wrong. I can't call the pass successfully. Items are not created successfully ...
Someone!?!!?
Thanks guys!!!!
Solution 1:[1]
Issue resolved. I needed to add a loop.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Estevao FPM |