post(url, [body], [params])
参数 | 类型 | 描述 |
---|---|---|
url | 字符串 | HTTP URL。如果设置了 baseURL,则只提供路径。 |
请求体 (可选) | null / string / object / ArrayBuffer / SharedArray | 请求体;对象为 x-www-form-urlencoded 格式。要省略请求体,请设为 null 。 |
参数 (可选) | null 或 对象 {} | 此特定请求的附加参数。 |
返回值
类型 | 描述 |
---|---|
Response | HTTP Response 对象。 |
示例
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',
});
}