Created
August 28, 2017 19:41
-
-
Save loopDelicious/213881bc1d4c8f64e1404aa7c7cbb413 to your computer and use it in GitHub Desktop.
Example of writing to a local file
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 fs = require('fs'); | |
var bodyParser = require('body-parser'); | |
var app = express(); | |
app.use(bodyParser.urlencoded({ extended: true })); | |
app.use(bodyParser.json()); // Body parser use JSON data | |
app.post('/launches', function(req, res) { | |
var outputFilename = './spaceReport.json'; // path of the file to output | |
fs.writeFileSync(outputFilename, JSON.stringify(JSON.parse(req.body.payload), null, 4)); // write to the file system | |
res.send('Saved to ' + outputFilename); | |
}); | |
var port = 3000; | |
app.listen(port); | |
console.log('Express started on port %d ...', port); |
Thank you!
That's fine it works. Thanks
Thank you!
If you're running into a syntax error using the Payload Fix, the quotes around 50mb are typographic quotes and you would need to change them to single or double quotes.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If receiving this error: “PayloadTooLargeError: request entity too large”
maybe try: