菜单
文档breadcrumb arrow Grafana k6breadcrumb arrow JavaScript APIbreadcrumb arrow jslibbreadcrumb arrow httpxbreadcrumb arrow post(url, [body], [params])
开源

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

参数类型描述
url字符串HTTP URL。如果设置了 baseURL,则只提供路径。
请求体 (可选)null / string / object / ArrayBuffer / SharedArray请求体;对象为 x-www-form-urlencoded 格式。要省略请求体,请设为 null
参数 (可选)null 或 对象 {}此特定请求的附加参数

返回值

类型描述
ResponseHTTP Response 对象。

示例

JavaScript
import { Httpx } from 'https://jslib.k6.io/httpx/0.1.0/index.js';

const session = new Httpx({
  baseURL: 'https://quickpizza.grafana.com',
  timeout: 20000, // 20s timeout.
});

export default function testSuite() {
  const resp = session.post(`/api/json`, {
    first_name: 'Mr',
    last_name: 'Croco',
  });
}