Is my express post request is correct?
<p>I'm trying to understand how Post Request works with express. I my case I would like to be able to update an web API call (is this the right term ?) with Google Analytics API. Most of the examples I found here or there are about handling post message or sign in operation. </p>

<p>Following this <a href="http://www.vardump.pw/sc?id=is38988886" rel="nofollow">question</a> here is what I have understand. On the front-end, using axios here is what I need to pass :</p>

<pre><code>axios.post("http://localhost:3000/endpoints", my_parameters)
</code></pre>

<p>I can easily send this on the server side with react/redux. however on the server side, I'm kind of lost. I've got the following API call :</p>

<pre><code>var key = require('./client_id.json')
var jwtClient = ...

var VIEW_ID = "ga:80820965";

var authorize = function( cb ) {
  jwtClient.authorize(function(err) {
    if (err) {
      console.log(err);
      return;
    } else {
      if ( typeof cb === "function") {
        cb();
      }
    }
  });
}

var queryData = function(req, res) {
  authorize(function() {
    analytics.data.ga.get({
      'auth': jwtClient,
      'ids': VIEW_ID,
      'metrics': 'ga:uniquePageviews',
      'dimensions': 'ga:pagePath',
      'start-date': '30daysAgo',
      'end-date': 'yesterday',
      'sort': '-ga:uniquePageviews',
      'max-results': 10,
    }, function (err, response) {
      if (err) {
        console.log(err);
        return;
      }
      res.send(response);
    }); 
  });
}

module.exports = {
    queryData
};
</code></pre>

<p>and my express server set-up :</p>

<pre><code>const app = express();

app.use('/', express.static('public'));
app.use('/', express.static('src'));

var ga = require('./src/apicall/gadata');

app.listen(process.env.PORT || 3000);

app.set('views', './src/views');      
app.set('view engine', 'ejs');

app.use('/gadata', ga.queryData);
</code></pre>

<p>so after I've dispatched my <code>axios.post</code>, how do I handle it in my <code>server.babel.js</code> file ? </p>

<p>I guess I need to use a structure like this :</p>

<pre><code>router.get('/newUser', (req, res) =&gt; {
  TestUser.save({
    name: 'sawyer',
    email: 'sawyer@test.com'
  }).then((result) =&gt; {
    console.log('Saved!')
    res.send(result)
  })
})
</code></pre>

<p>but I don't really know how I should refactor it to pass my parameters so I can actually update my google analytics api call ? </p>

<p>thanks.</p>