I have an [express](http://expressjs.com/) API and a [ReactJs](https://reactjs.org/) front-end. I try to make a POST call from my front-end directly to the local API.

For this I'm using [axios](https://github.com/axios/axios).

The request is working fine when I set the parameters directly inside the query string but is always getting on timeout if I try to add the parameters through the `data` attribute of the `axios.post()` method.

**Working**

```
axios.post(`http://localhost:5001/site/authenticate?username=demo&password=demo`)

```

**Not working**

```
const payload = {
    "username":"mh",
    "password":"mh"
}
axios.post(`http://localhost:5001/site/authenticate`, payload)

```

My express server:

```
const express = require('express');
const bodyParser = require('body-parser');
const morgan = require('morgan');
const jwt = require('jsonwebtoken'); // used to create, sign, and verify tokens
var cors = require('cors');

const app = express();
const port = process.env.API_PORT || 5001;

app.use(cors());
app.set('secret', process.env.API_SECRET);

app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

app.use(morgan('dev'));

app.use((req, res, next) => {
    let data = '';
    req.setEncoding('utf8');
    req.on('data', (chunk) => {
        data += chunk;
    });
    req.on('end', () => {
        req.rawBody = data;
        next();
    });
});

// Allow CORS
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();
});

// SITE ROUTES -------------------
const siteRoutes = express.Router(); 

siteRoutes.post('/authenticate', function(req, res) {
    console.log('auth');
    getDocument(usersBucket, req.query.username)
        .then((doc) => {
            console.log("Authentification... TODO");

            // return the information including token as JSON
            res.json({
                success: true,
                status: 200,
                token: token
            });
        })
        .catch(() => {
            res.status(401).json({ success: false, message: 'Authentification failed. User not found.' });
        });
});

// route middleware to verify a token
siteRoutes.use(function(req, res, next) {
    const token = req.body.token || req.query.token || req.headers['x-access-token'];

    if (token) {
    // verifies secret and checks exp
    jwt.verify(token, app.get('secret'), function(err, decoded) {
            if (err) {
                return res.json({ success: false, message: 'Failed to authenticate token.', status: 401 });       
            } else {
                req.decoded = decoded;
                next();
            }
    });

  } else {
    return res.status(403).send({ 
        success: false, 
        message: 'No token provided.' 
    });
  }
});

siteRoutes.get('/', function(req, res) {
  res.json({ message: 'Welcome!' });
});

app.use('/site', siteRoutes);

app.listen(port, () => {
    logger.log(`Express server listening on port ${port}`);
});

```

Any idea? Thanks.

### Update

I replaced my route just to see if I got in or not (without worrying about parameters):

```
siteRoutes.post('/authenticate', function(req, res) {
    console.log("go in");
    res.json({
        success: true,
        status: 200,
    });
});

```

But my `console.log` is not showing hen I use the payload (it is when I do not).