How to access the request body when POSTing using Node.js and Express
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.post('/post-test', (req, res) => {
console.log('Got body:', req.body);
res.sendStatus(200);
});
app.listen(8080, () => console.log(`Started server at http://localhost:8080!`));const express = require('express');
const app = express();
app.use(express.json({extended: false})); //This is the line that you want to add
app.post('/postroute', (req, res) => {
console.log('body :', req.body);
res.sendStatus(200);
});
Also in JavaScript:
- javascript recursive fibonacci
- FizzBuzz
- mysql json_array_append
- geolocation speed
- node js get files in dir
- how to send json data in fetch request body
- Aspect Ratio height react
- mongodb delete duplicate documents
- ajax call to load a page on scrolling
- leaflet change marker location
- how to do bubble sort in javascript
- compare strings js
- event.persist()
- how to check the listeners on an object js
- for Loop continue
- javascript date parse yyyy-mm-dd
- string date to date in javascript
- Please update your node with version 8.11.3 or greater (but not version 10)
- react how to manipulate children
- vue js default props
- object json parse nestjs
- async map js
- http request javascript
- how to download and install ssms in windows 10