Sto usando Node.js e voglio vedere tutti i parametri che sono stati postati nel mio script. Per arrivare alla mia funzione, nel mio routes/index.js
sto facendo:Perché req.params restituisce un array vuoto?
app.post('/v1/order', order.create);
Poi nella mia funzione, ho:
exports.create = function(req, res, next) {
console.log(req.params);
ma è la restituzione di un array vuoto. Ma quando lo faccio:
exports.create = function(req, res, next) {
console.log(req.param('account_id'));
Ottengo i dati. Quindi sono un po 'confuso su cosa sta succedendo qui.
Si noti che 'req.param()' è [deprecato] (http://expressjs.com/en/4x/api.html#req.param). –