Skip to content

Instantly share code, notes, and snippets.

@MBehtemam
Last active November 21, 2018 22:36
Show Gist options
  • Save MBehtemam/35f3fc9d5eaa1b724f4e1e17ea8fa1aa to your computer and use it in GitHub Desktop.
Save MBehtemam/35f3fc9d5eaa1b724f4e1e17ea8fa1aa to your computer and use it in GitHub Desktop.
Sample server
const express = require("express");
const bodyParser = require("body-parser");
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.get("/", (req, res) => {
res.json({ hope: "loop" });
});
app.post("/", (req, res) => {
const { name } = req.body;
if (!name || name === undefined) {
res.sendStatus(400);
} else {
res.json({ input: name });
}
});
module.exports = app;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment