Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/k6/next/javascript-api/k6-http/query.md, or by sending Accept: text/markdown to https://grafana.com/docs/k6/next/javascript-api/k6-http/query/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
This is documentation for the next version of Grafana k6 documentation. For the latest stable release, go to the latest version.
query( url, [body], [params] )
http.query() issues an HTTP QUERY request, defined in RFC 10008. QUERY is safe and idempotent like GET, but carries a request body, which makes it a good fit for queries that are too large, complex, or sensitive to put in the URL.
For object bodies without file uploads, refer to the form encoding rules.
Returns
| Type | Description |
|---|---|
Response | HTTP Response object. |
Example
import http from 'k6/http';
const url = 'https://quickpizza.grafana.com/api/query';
export default function () {
const headers = { 'Content-Type': 'application/json' };
const query = { maxPrice: 15, filters: ['vegetarian'] };
const res = http.query(url, JSON.stringify(query), { headers: headers });
console.log(JSON.parse(res.body).json);
}Was this page helpful?
Related resources from Grafana Labs

