Do I have to use k6/http


I’ve just started using K6 and a question about making requests.

My API endpoints have our own authentication as set in headers. We have an internal npm package to make these authenticated requests, but I wanted to ask is it actually possible for me to use this to make the requests - and get all the goodies, like validation and metrics as I would otherwise.

So basically instead of:

import http from "k6/http";

let response = http.get(url);

Use my own:

import myHttpRequest from "myLibrary";

let response = myHttpRequest.get(url);


Hi @psa,
In the sense that … there is no other way to make HTTP requests(k6 is not nodejs or browser based) - you do need to use k6/http to make requests.

You can do make a library that uses k6/http and use that though. Reusing a npm library won’t just be possible (unless it already has a dependency ingestion on the call that actually make the HTTP requests), but you can rewrite it to use k6/http, which will probably take less time then trying to make it work with both ;).

Good luck

Thanks for clearing.

That approach seems the quickest. To fork our library, and make the requests within there K6 requests.

Hopefully, it won’t be too painful.