title: How to pass response object to external callback function in puppeteer?
body: <p>I was trying to modularize my puppeteer code and wanted to get the page.on event functionality to a different file. looks like I am not being able to send the response object to the external file. How can I do it?</p>
  <p><strong>main.js</strong></p>
  <pre><code>const puppeteer = require('puppeteer');
  const sniffer = require('./sniffer.js')
  
  (async () =&gt; {
    const browser = await puppeteer.launch()
    const page = await browser.newPage()
    await page.goto('https://www.google.com/')
  
    page.on('response', sniffer(response) );
    
    /** currently working like this
    page.on('response', async (response) =&gt; { 
    /** sniffer code **/
    })
    **/
  
    await browser.close()
  })()
  </code></pre>
  <p><strong>sniffer.js</strong></p>
  <pre><code>async function sniffResponse (response) {
      /** sniffer code **/
  }
  
  module.exports.sniffer = sniffResponse;
  </code></pre>