-2

I need some example where we are capturing dynamic value and passing it into the subsequent request.

halfer
  • 19,824
  • 17
  • 99
  • 186
Engineer
  • 21
  • 2
  • Welcome! To ask [On Topic question](https://stackoverflow.com/help/on-topic), please read [Question Check list](https://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist) and the [perfect question](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/) and how to create a [Minimal, Complete and Verifiable Example](https://stackoverflow.com/help/mcve) and [take the tour](https://stackoverflow.com/tour). **We are very willing to help you fix your code, but we dont write code for you.** – Dave Nov 24 '18 at 12:51

1 Answers1

0

You can do that via the http.Response object that each HTTP request returns: https://docs.k6.io/docs/response-k6http

A simple example that uses httpbin.org:

import http from "k6/http";

export default function (data) {
    let resp1 = http.get("https://httpbin.org/anything");

    let resp2 = http.post("https://httpbin.org/post", { myip: resp1.json().origin });

    console.log(resp2.body)
}
na--
  • 1,016
  • 7
  • 9
  • I am also looking - How can we handle single sign on . I have an application which takes username and password during launch and then login. So If you know loadrunner we use web_set_user, but here in K6 how can we handle this ?? – Engineer Dec 01 '18 at 02:55