0

I am working on a project that requires me to wait until a variable is no longer null and then return it, it that possiable? For example, I have set a value returnValue in the start of the script like this

let returnValue = null;

and I have something that would updates it

      await page.on("request", async request => {
        const requestHeaders = request.headers(); //getting headers of your request
        // console.log(requestHeaders)
        const headers = JSON.stringify(requestHeaders)
        if (headers.includes("my-little-web-app")) {
          await fs.writeFileSync("./node_modules/ytcf/headers.json", JSON.stringify(requestHeaders, null, 4)),
            function (err, res) {
              if (err) throw err;
            };
            returnValue = headers
            console.log(headers);
            return headers
        }

And I have returned it

return returnValue

The output: null (or undefined)

How can I export the value of something-else which is passed to x? Thanks

YueYue
  • 13
  • 4

0 Answers0