Skip to content

Instantly share code, notes, and snippets.

@Gioyik
Created August 27, 2021 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gioyik/4396db8f738e0c98287c51d4b54ac1c5 to your computer and use it in GitHub Desktop.
Save Gioyik/4396db8f738e0c98287c51d4b54ac1c5 to your computer and use it in GitHub Desktop.
const express = require('express')
const app = express()
const port = 3000
const fs = require('fs')
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
let counter = 0
app.post('/', (req, res) => {
fs.writeFile(`response${counter}.json`, JSON.stringify(req.body), (err) => {
if (err) {
console.log("something happened saving the file")
}
counter++
console.log("body response was saved!")
})
res.status(200)
})
app.listen(port, () => console.log(`Running`))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment