title: How to receive data posted by "navigator.sendbeacon" on node.js server?
body: <p>I am using new browser feature(<a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon">navigator.sendBeacon</a>) to POST async data to node.js server.</p>
  
  <p>But i am unable to receive it on node server. So could any one tell me how to receive data posted by sendBeacon on node server.</p>
  
  <p><strong>node server code is:</strong></p>
  
  <pre><code>var express = require('express');
  var app = express();
  var bodyParser = require('body-parser');
  
  // set cross origin header to allow cross-origin request.
  app.use(function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    next();
  });
  
  app.use(bodyParser.json());
  
  app.post('/',function(req,res){
      console.log('i got the request',req.body)
  });
  
  var server = app.listen(3000, function() {
      console.log('Express is listening to http://localhost:3000');
  });
  </code></pre>
  
  <p><strong>client side code</strong></p>
  
  <pre><code>navigator.sendBeacon('http://localhost:3000/','{"a":9}')
  </code></pre>