“req.body” Respostas de código

Parse JSON Express

// Update for Express 4.16+
// Starting with release 4.16.0, a new express.json() middleware is available.
var express = require('express');
var app = express();

app.use(express.json());

app.post('/', function(request, response){
  console.log(request.body);      // your JSON
   response.send(request.body);    // echo the result back
});

app.listen(3000);
Mushy Magpie

JSON EXPRESSO DE URLECODADO

var express = require('express')

var app = express()

app.use(express.json()) // for parsing application/json
app.use(express.urlencoded({ extended: true })) // for parsing application/x-www-form-urlencoded

app.post('/profile', function (req, res, next) {
  console.log(req.body)
  res.json(req.body)
})
Healthy Hare

req.body

(req.body, ' ' , ' ') --> here req is the parameter of your function and using this parameter your can access the properties over then url.
so look this example
suppose this is form 
<form>
enter the name : <input type="text" name="name">
<button type ="submit"> submit </button> 
</form>

so if you want to access the name -- which is filled by the user end.
so for this you can 
do like this->   console.log(req.body.name);  -- this will print the name (property) in console.
Jolly Jay

Respostas semelhantes a “req.body”

Perguntas semelhantes a “req.body”

Procure respostas de código populares por idioma

Procurar outros idiomas de código