Create a new header based on the result of Javascript method

I want to add a new header ‘new-header’ to the request if one of my javascript methods returns true. I’m new on this, can anyone help me?

Hello, in your javascript file you can do this
context.setVariable(‘request.header.’,‘’);

example for a header called “new-header”, applied to the Request object:

if (myFunction()) { // truthy
  context.setVariable('request.header.new-header','any-value-here');
}