I’ve created a custom function for such purpose - maybe you can get some use of it.
import {URLSearchParams} from 'https://jslib.k6.io/url/1.0.0/index.js';
export function securedGetWithParams(url, params, payload) {
let searchParams = new URLSearchParams();
for (const [key, value] of Object.entries(params)) {
searchParams.append(key, value);
}
return http.get(`${url}?${searchParams.toString()}`, payload);
}
@Gerard you are using string in your origianl example while you seem to want to use templates literals. To do that you need to use a `(backtick) instead of '(single quote).