<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Response on Grafana Labs</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/response/</link><description>Recent content in Response on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/k6/v2.3.x/javascript-api/k6-http/response/index.xml" rel="self" type="application/rss+xml"/><item><title>Response.clickLink( [params] )</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/response/response-clicklink/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/response/response-clicklink/</guid><content><![CDATA[&lt;h1 id=&#34;responseclicklink-params-&#34;&gt;Response.clickLink( [params] )&lt;/h1&gt;
&lt;p&gt;Create and make a request corresponding to a link, found in the HTML of response, being clicked. By default it will look for the first &lt;code&gt;a&lt;/code&gt; tag with a &lt;code&gt;href&lt;/code&gt; attribute in the HTML, but this can be overridden using the &lt;code&gt;selector&lt;/code&gt; option.&lt;/p&gt;
&lt;p&gt;This method takes an object argument where the following properties can be set:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Param&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;selector&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;A selector string passed to 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-html/selection/selection-find/&#34;&gt;Selection.find(selector)&lt;/a&gt; to locate the link to click. By default this is &lt;code&gt;&amp;quot;a[href]&amp;quot;&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;params&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;A 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/params/&#34;&gt;Params&lt;/a&gt; object that will be forwarded to the link click request. Can be used to set headers, cookies etc.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/response/&#34;&gt;Response&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;The link click response&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

export default function () {
  // Request page with links
  let res = http.get(&amp;#39;https://quickpizza.grafana.com/admin&amp;#39;);

  // Now, click the 4th link on the page
  res = res.clickLink({ selector: &amp;#39;a:nth-child(1)&amp;#39; });
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="responseclicklink-params-">Response.clickLink( [params] )&lt;/h1>
&lt;p>Create and make a request corresponding to a link, found in the HTML of response, being clicked. By default it will look for the first &lt;code>a&lt;/code> tag with a &lt;code>href&lt;/code> attribute in the HTML, but this can be overridden using the &lt;code>selector&lt;/code> option.&lt;/p></description></item><item><title>Response.html()</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/response/response-html/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/response/response-html/</guid><content><![CDATA[&lt;h1 id=&#34;responsehtml&#34;&gt;Response.html()&lt;/h1&gt;
&lt;p&gt;Parses response as HTML and populate a 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-html/selection/&#34;&gt;Selection&lt;/a&gt; object.&lt;/p&gt;
&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-html/selection/&#34;&gt;Selection&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;A Selection object&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

export default function () {
  const res = http.get(&amp;#39;https://stackoverflow.com&amp;#39;);

  const doc = res.html();
  doc
    .find(&amp;#39;link&amp;#39;)
    .toArray()
    .forEach(function (item) {
      console.log(item.attr(&amp;#39;href&amp;#39;));
    });
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="responsehtml">Response.html()&lt;/h1>
&lt;p>Parses response as HTML and populate a
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-html/selection/">Selection&lt;/a> object.&lt;/p>
&lt;h3 id="returns">Returns&lt;/h3>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-html/selection/">Selection&lt;/a>&lt;/td>
&lt;td>A Selection object&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="example">Example&lt;/h3>
&lt;div class="code-snippet ">&lt;div class="lang-toolbar">
&lt;span class="lang-toolbar__item lang-toolbar__item-active">JavaScript&lt;/span>
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;div class="lang-toolbar__border">&lt;/div>
&lt;/div>&lt;div class="code-snippet ">
&lt;pre data-expanded="false">&lt;code class="language-javascript">import http from &amp;#39;k6/http&amp;#39;;
export default function () {
const res = http.get(&amp;#39;https://stackoverflow.com&amp;#39;);
const doc = res.html();
doc
.find(&amp;#39;link&amp;#39;)
.toArray()
.forEach(function (item) {
console.log(item.attr(&amp;#39;href&amp;#39;));
});
}&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div></description></item><item><title>Response.json( [selector] )</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/response/response-json/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/response/response-json/</guid><content><![CDATA[&lt;h1 id=&#34;responsejson-selector-&#34;&gt;Response.json( [selector] )&lt;/h1&gt;
&lt;p&gt;Parses the response body data as JSON and returns a JS object or array. This call caches the deserialized JSON data, additional calls will return the cached data. An optional selector can be specified to extract a specific part of the data, see &lt;a href=&#34;https://github.com/tidwall/gjson#path-syntax&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;here for selector syntax&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This method takes an object argument where the following properties can be set:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Param&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;selector&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;An optional selector can be specified to extract a specific part of the data, see &lt;a href=&#34;https://github.com/tidwall/gjson#path-syntax&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;here for selector syntax&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Object or array&lt;/td&gt;
              &lt;td&gt;Returns the response body as JSON object.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

export default function () {
  const res = http.get(&amp;#39;https://quickpizza.grafana.com/api/json?foo=bar&amp;#39;);

  console.log(res.json());
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="responsejson-selector-">Response.json( [selector] )&lt;/h1>
&lt;p>Parses the response body data as JSON and returns a JS object or array. This call caches the deserialized JSON data, additional calls will return the cached data. An optional selector can be specified to extract a specific part of the data, see &lt;a href="https://github.com/tidwall/gjson#path-syntax" target="_blank" rel="noopener noreferrer">here for selector syntax&lt;/a>.&lt;/p></description></item><item><title>Response.submitForm( [params] )</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/response/response-submitform/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/response/response-submitform/</guid><content><![CDATA[&lt;h1 id=&#34;responsesubmitform-params-&#34;&gt;Response.submitForm( [params] )&lt;/h1&gt;
&lt;p&gt;Fill in and submit form found in HTML of response. By default it will look for the first &lt;code&gt;form&lt;/code&gt; tag in the HTML, but this can be overridden using the &lt;code&gt;formSelector&lt;/code&gt; option. To set/override the form fields you set properties of an object in the &lt;code&gt;fields&lt;/code&gt; option.&lt;/p&gt;
&lt;p&gt;This method takes an object argument where the following properties can be set:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Param&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;formSelector&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;A selector string passed to 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-html/selection/selection-find/&#34;&gt;Selection.find(selector)&lt;/a&gt; to locate the form to fill in and submit. By default this is &lt;code&gt;&amp;quot;form&amp;quot;&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;fields&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;The form fields to set/override. The keys are the form fields names and the values are the form field values.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;submitSelector&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;A selector string used to locate the submit button in the form. By default this is &lt;code&gt;&#39;[type=&amp;quot;submit&amp;quot;]&#39;&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;params&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;A 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/params/&#34;&gt;Params (k6/http)&lt;/a&gt; object that will be forwarded to the form submit request. Can be used to set headers, cookies etc.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/response/&#34;&gt;Response (k6/http)&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;The form submit response.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;
import { sleep } from &amp;#39;k6&amp;#39;;

export default function () {
  // Request page containing a form
  let res = http.get(&amp;#39;https://quickpizza.grafana.com/admin&amp;#39;);

  // Now, submit form setting/overriding some fields of the form
  res = res.submitForm({
    formSelector: &amp;#39;form&amp;#39;,
    fields: { username: &amp;#39;test&amp;#39;, password: &amp;#39;test2&amp;#39; },
  });
  sleep(3);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="responsesubmitform-params-">Response.submitForm( [params] )&lt;/h1>
&lt;p>Fill in and submit form found in HTML of response. By default it will look for the first &lt;code>form&lt;/code> tag in the HTML, but this can be overridden using the &lt;code>formSelector&lt;/code> option. To set/override the form fields you set properties of an object in the &lt;code>fields&lt;/code> option.&lt;/p></description></item></channel></rss>