Undefined response on k6 http requests with mutiple VUs

The below code works for 1 VU but not mutiple VUs

export const options = {
  vus:2,

  iterations: 2,

};
let jwtToken
group("1. GET JWT", function () {

       = http.post(url, formData, {

        headers: headers

      });

    });

group("2. GET PROFILE", function () {

          response = http.get('PROFILE-URL, {
            headers: {
              'Authorization': `Bearer ${jwtToken}`
            }
          });

      });

When run for 10 VUs,
9 of the VU will result in JWT token group returning undefined, and this undefined is pass to GROUP 2 which cause endpoint failure.
The other VU will success.

Please advice how can i make this works for mutiple VUs.

Hi, welcome to the forum.

Can you please fix and reformat your sample script? I can’t reproduce this otherwise.

Also, let us know your k6 version (output of k6 version).