Last active
January 11, 2019 11:33
-
-
Save pablocattaneo/39f04b23b4044f9b1f06c3e0c0a27132 to your computer and use it in GitHub Desktop.
#node #express
Source: https://www.udemy.com/nodejs-the-complete-guide/learn/v4/t/lecture/11566290?start=15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// npm install --save body-parser | |
const express = require('express') | |
const app = express() | |
const bodyParser = require('body-parser') | |
//This example shows a middleware function with no mount path. The function is executed every time the app receives a request. | |
app.use(bodyParser.urlencoded({extended:false})) // Parse x-form-www-urlencoded | |
app.use('/insert', (req, res) => { | |
console.log(req.body) | |
res.send('insert!') | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// npm install --save body-parser | |
const express = require('express') | |
const app = express() | |
const bodyParser = require('body-parser') | |
//This example shows a middleware function with no mount path. The function is executed every time the app receives a request. | |
app.use(bodyParser.json()) // Parse json format | |
app.use('/insert', (req, res) => { | |
console.log(req.body) | |
res.send('insert!') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment