Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 1.51 KB

10-patch- url- -body-- -params- -.md

File metadata and controls

38 lines (27 loc) · 1.51 KB
title description excerpt
patch( url, [body], [params] )
Issue an HTTP PATCH request.
Issue an HTTP PATCH request.
Parameter Type Description
url string / HTTP URL Request URL (e.g. http://example.com).
body (optional) string / object / ArrayBuffer Request body; objects will be x-www-form-urlencoded.
params (optional) object Params object containing additional request parameters

Returns

Type Description
Response HTTP Response object.

Example

import http from 'k6/http';

const url = 'https://httpbin.test.k6.io/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).json.name);
}