Menu

Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.

DocumentationGrafana k6JavaScript APIk6/httpoptions( url, [body], [params] )
Open source

options( url, [body], [params] )

ParameterTypeDescription
urlstring /HTTP URLRequest URL (e.g. http://example.com).
body (optional)string / object / ArrayBufferRequest body; objects will be x-www-form-urlencoded.
params (optional)objectParams object containing additional request parameters.

Returns

TypeDescription
ResponseHTTP Response object.

Example

JavaScript
import http from 'k6/http';

const url = 'https://httpbin.test.k6.io/';

export default function () {
  const params = { headers: { 'X-MyHeader': 'k6test' } };
  const res = http.options(url, null, params);
  console.log(res.headers['Allow']);
}