patch( url, [body], [params] )
参数 | 类型 | 描述 |
---|---|---|
url | string / HTTP URL | 请求 URL (例如 http://example.com )。 |
body (可选) | string / object / ArrayBuffer | 请求体;对象将被 x-www-form-urlencoded 编码。 |
params (可选) | object | Params 对象,包含额外的请求参数 |
返回值
类型 | 描述 |
---|---|
Response | HTTP Response 对象。 |
示例
import http from 'k6/http';
const url = 'https://quickpizza.grafana.com/api/patch';
export default function () {
const headers = { 'Content-Type': 'application/json' };
const data = { name: 'Bert' };
const res = http.patch(url, JSON.stringify(data), { headers: headers });
console.log(JSON.parse(res.body).name);
}