Skip to content

Instantly share code, notes, and snippets.

@Reine0017
Created June 25, 2023 11:10
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 Reine0017/e4656f44d5424bb2f4e0eae986382d7c to your computer and use it in GitHub Desktop.
Save Reine0017/e4656f44d5424bb2f4e0eae986382d7c to your computer and use it in GitHub Desktop.
NodeJS set up - step 1
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