Created
February 26, 2020 22:48
-
-
Save madson/932962a5aac6ad2c71b523cd134a6402 to your computer and use it in GitHub Desktop.
This file contains 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
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