Created
June 25, 2023 11:10
-
-
Save Reine0017/e4656f44d5424bb2f4e0eae986382d7c to your computer and use it in GitHub Desktop.
NodeJS set up - step 1
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 bodyParser = require('body-parser'); | |
const app = express(); | |
const port = process.env.PORT || 3000; | |
app.use(bodyParser.json()); // for parsing application/json | |
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded | |
app.get('/', (req, res) => { | |
res.send('Hello, World!'); | |
}); | |
app.post("/plan", function(req, res) { | |
let occasion = req.body.occasion; | |
let pax = req.body.pax; | |
let budget = req.body.budget; | |
let theme = req.body.theme; | |
let country = req.body.theme | |
console.log(occasion, pax, budget, theme, country) | |
res.json("OK"); | |
}); | |
app.listen(port, () => { | |
console.log(`Server is running on http://localhost:${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment