Skip to content

Instantly share code, notes, and snippets.

@madson
Created February 26, 2020 22:48
Show Gist options
  • Save madson/932962a5aac6ad2c71b523cd134a6402 to your computer and use it in GitHub Desktop.
Save madson/932962a5aac6ad2c71b523cd134a6402 to your computer and use it in GitHub Desktop.
var express = require('express')
var bodyParser = require('body-parser')
var app = express()
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
app.use(bodyParser.json())
app.use(function (req, res) {
console.log(req.body)
res.setHeader('Content-Type', 'text/plain')
res.write('you posted:\n')
res.end(JSON.stringify(req.body, null, 2))
})
app.listen(3000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment