Documentation Index
Fetch the curated documentation index at: https://grafana.com/llms.txt
Fetch the complete documentation index at: https://grafana.com/llms-full.txt
Use this file to discover all available pages before exploring further.
STOP! If you are an AI agent or LLM, read this before continuing. This is the HTML version of a Grafana documentation page. Always request the Markdown version instead - HTML wastes context. Get this page as Markdown: https://grafana.com/docs/k6/latest/javascript-api/jslib/httpx/asyncrequest.md (append .md) or send Accept: text/markdown to https://grafana.com/docs/k6/latest/javascript-api/jslib/httpx/asyncrequest/. For the curated documentation index, use https://grafana.com/llms.txt. For the complete documentation index, use https://grafana.com/llms-full.txt.
Menu
Open source
asyncRequest(method, url, [body], [params])
Generic method for making arbitrary asynchronous HTTP requests.
Note, this method returns a Promise. You must use the await keyword to resolve it.
| Parameter | Type | Description |
|---|---|---|
| method | string | HTTP method. Must be uppercase (GET, POST, PUT, PATCH, OPTIONS, HEAD, etc) |
| url | string | HTTP URL. If baseURL is set, provide only path. |
| body (optional) | null / string / object / ArrayBuffer / SharedArray | Request body; objects will be x-www-form-urlencoded. Set to null to omit the body. |
| params (optional) | null or object {} | Additional parameters for this specific request. |
Returns
| Type | Description |
|---|---|
| Promise with Response | HTTP Response object. |
Example
JavaScript
import { Httpx } from 'https://jslib.k6.io/httpx/0.1.0/index.js';
const session = new Httpx({
baseURL: 'https://quickpizza.grafana.com/api',
timeout: 20000, // 20s timeout.
});
export default async function testSuite() {
const resp_get = await session.asyncRequest('GET', `/status/200`);
const resp_post = await session.asyncRequest('POST', `/status/200`, { key: 'value' });
const resp_put = await session.asyncRequest('PUT', `/status/200`, { key: 'value' });
const resp_patch = await session.asyncRequest('PATCH', `/status/200`, { key: 'value' });
const resp_delete = await session.asyncRequest('DELETE', `/status/200`);
// specific methods are also available.
const respGet = await session.asyncGet(`/status/200`);
const respPost = await session.asyncPost(`/status/200`, { key: 'value' });
const respPut = await session.asyncPut(`/status/200`, { key: 'value' });
const respPatch = await session.asyncPatch(`/status/200`, { key: 'value' });
const respDelete = await session.asyncDelete(`/status/200`);
}Was this page helpful?
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:
Video

Performance testing and observability in Grafana Cloud
Optimize user experiences with Grafana Cloud. Learn real-time insights, performance testing with k6, and continuous validation with Synthetic Monitoring.
Events

User-centered observability: load testing, real user monitoring, and synthetics
Learn how to use load testing, synthetic monitoring, and real user monitoring (RUM) to understand end users' experience of your apps. Watch on demand.
Choose a product
Viewing: v2.0.x (latest)
Find another version
Scroll for more