Created
April 28, 2020 18:04
-
-
Save yaasita/99311e1dd298e61170373bcbaf6b053e 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
const express = require("express"); | |
const app = express(); | |
const port = 3000; | |
const concat = require("concat-stream"); | |
app.use(function (req, res, next) { | |
req.pipe( | |
concat(function (data) { | |
req.body = data; | |
next(); | |
}) | |
); | |
}); | |
const fs = require('fs'); | |
app.post("/api", (req, res) => { | |
console.log(req.method); | |
console.log(req.body.toString()); | |
console.log(req.headers); | |
fs.writeFileSync("/tmp/rawdata", req.body); | |
res.send("Hello!"); | |
}); | |
app.listen(port, () => | |
console.log(`Example app listening at http://localhost:${port}`) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment