API key missing error even when passing key

I am using a simple script provided as example in GitHub - catchpoint/WebPageTest.api-nodejs: WebPageTest API wrapper for NodeJS

script

> const WebPageTest = require("webpagetest");
> 
> const wptServer = "www.webpagetest.org";
> 
> const options = {
> 
> "X-WPT-API-KEY": "Passing actual API key in test"
> 
> };
> 
> const wpt = new WebPageTest(wptServer, options);
> 
> const siteToTest = "https://staging-app.deriv.com";
> 
> wpt.runTest(siteToTest, (err, data) => {
> 
> console.log(err || data);
> 
> });

But i am getting error response as missing API key can you please help what is wrong here, thanks.

Hi There,

Its mandatory to pass the API key in the header now.
Could you please try the below code and check if it works for you.

const WebPageTest = require("webpagetest");

const wptServer = "www.webpagetest.org";

const options = {
  headers: {
    "X-WPT-API-KEY": "Passing actual API key in test"
  }
};

const wpt = new WebPageTest(wptServer, options);

const siteToTest = "https://staging-app.deriv.com";

wpt.runTest(siteToTest, (err, data) => {
  console.log(err || data);
});

Regards
Atib