How to parameterize the current API by referencing the response value of the previous API?

Hi guys,when use k6, how should I parameterize the current API by referencing the response value of the previous API? Like the example below

Hi @sunnini,
can you clarify your intention, please? Do you want reference values from the same request in a previous iteration or from a different request in the same iteration?

Consider to post a partial k6 script with your attempt it could help to suggest concrete solutions.

Let me know.

Hello @codebien ,here’s my appeal, I have two business scenarios,bussiness_1 & bussiness_2, bussiness_1 has two interfaces(login & get_userinfo) , bussiness_2 has one interface(create_order)
For how to use K6 to run load testing, I have two questions,as follows

  1. How to pass variables between login and get_userinfo ? Implement login to pass the response value(openid+token) to get_userinfo each time.
  2. How to run load testing on business_1 and business_2 in parallel ?

Can you provide a detailed k6 example for these two problems? Thanks a lot. Here is the test script I designed by using JMeter

Hi @sunnini,

How to pass variables between login and get_userinfo ? Implement login passes the response value(openid+token) to get_userinfo each time.

You should be able to code a similar solution using the following example.

How to run load testing on business_1 and business_2 in parallel ?

You can code them as different scenarios. If you want the result from the login process to be available as an input for business_1 and business_2 then you have to execute the login logic in the setup function.