Skip to content

Instantly share code, notes, and snippets.

@loopDelicious
Created August 28, 2017 19:41
Show Gist options
  • Save loopDelicious/213881bc1d4c8f64e1404aa7c7cbb413 to your computer and use it in GitHub Desktop.
Save loopDelicious/213881bc1d4c8f64e1404aa7c7cbb413 to your computer and use it in GitHub Desktop.
Example of writing to a local file
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);
@woozycode
Copy link

Thank you!

@makifyegin
Copy link

That's fine it works. Thanks

@Jesulayomy
Copy link

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