title: Using an Express app with MongoDB to execute a 'create' function on clients browser instead of the server
body: <p>I have created an internet speed test app using client speed, location, and ISP. Problem is that when this code is executed it pulls the speed, ISP and location of where the data centre is wherever it is deployed(in my example an AWS server in Virginia via Heroku). My thought is that I need this code to execute on the client's browser side instead of on the server. Is this possible using Express, Mongoose, and EJS?</p>
  <p>Relevant code posted below. This is from my controller. I didn't include the rest because it's just logic for something separate/render code.</p>
  <pre><code>function index(req, res, next) {
  
    let speedtest = new FastSpeedtest({
      token: hidden, // required
      verbose: false, // default: false
      timeout: 10000, // default: 5000
      https: true, // default: true
      urlCount: 5, // default: 5
      bufferSize: 8, // default: 8
      unit: FastSpeedtest.UNITS.Mbps, // default: Bps
      proxy: &quot;http://optional:auth@my-proxy:123&quot;, // default: undefined
    });
  
    speedtest.getSpeed().then((s) =&gt; {
        fetch(ipApiToken).then(function (response) {
          response.json().then((jsonData) =&gt; {
            res.render(&quot;testSpeed&quot;, { s, jsonData });
          });
        });
      })
      .catch((e) =&gt; {
        console.error(e.message);
      });
  }
  
  async function create(req, res, next) {
  
      let userIsp = req.body.isp
      let userSpeed = req.body.speed
      let userLocation = req.body.location
  
      let newSpeedTest = await importSpeed.speedModel.create({speed: Math.round(userSpeed),location: userLocation, isp: '', isp_id: ''});
  </code></pre>