How to use the k6/http.request function in k6

To help you get started, we’ve selected a few k6 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github loadimpact / postman-to-k6 / lib / shim / core.js View on Github external
function executeRequest ({
  name, id = guid(), method, address, data, headers, options, pre, auth, post
}) {
  try {
    enterRequest(name, id, method, address, data, headers)
    executePrerequest(postman[Pre], pre)
    const config = makeRequestConfig(method, address, data, headers, options)
    if (auth) {
      auth(config, Var)
    }
    const args = makeRequestArgs(config)
    const response = http.request(...args)
    if (post) {
      enterPost(response)
      executePostrequest(postman[Post], post, response)
      executeTests()
    }
    return response
  } finally {
    exitRequest()
  }
}
function namedRequest (name, index = 1) {