title: Using Express, how to pass a value to a .js file using sendFile?
body: <p>I'm trying to figure out how to pass data received when someone accesses a page and pass a value from the URL to a JavaScript file and store it as a value for a variable in that file and then send the file back.</p>
  
  <p>I've read that you can use templating engines to do this however I couldn't find one that allows you to do this with JS files (only could find HTML).</p>
  
  <p>Is it possible to do something like this:</p>
  
  <pre><code>app.get('/initial/:public_key', (req, res) =&gt; {
    res.sendFile(__dirname + '/public_scripts.js', {
      publicKey: req.params.public_key
    });
  });
  </code></pre>
  
  <p>If so what do I need to be able to do this?</p>