Skip to content

Instantly share code, notes, and snippets.

@prof3ssorSt3v3
Created January 22, 2020 14:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save prof3ssorSt3v3/af0294835b7fb9280d7950866c911695 to your computer and use it in GitHub Desktop.
Save prof3ssorSt3v3/af0294835b7fb9280d7950866c911695 to your computer and use it in GitHub Desktop.
"use strict";
const express = require("express");
const app = express();
app.get("/", (req, res) => {
console.log(req.headers);
console.log(req.url);
console.log(req.ip);
console.log(req.hostname);
console.log(req.method); //get
console.log(req.protocol); //http /https
console.log(req.path); // just the path part of the url
console.log(req.subdomains); // test.sales.example.com ['test','sales]
console.log(req.query); // querystring
console.log(req.params); // /user/72 /product/234234
// app.get("/user/:id") app.get("/product/:id")
// req.params.id
res.status(404).end();
});
//app.post("/thing");
app.listen(3000, err => {
if (err) {
console.log("there was a problem", err);
return;
}
console.log("listening on port 3000");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment