Start a Working Express Server

If you had a website at “example.com/” and wanted to serve a string such as “Hello World” to whoever visits the root domain you could do so easily using node and/or express:

app.get("/", function(req, res) {
  res.send("Hello World");
});

Also, with ES6+ you can save some typing by using ”=>” instead of “function,” which looks like:

app.get("/", (req, res) => {
  res.send("Hello World");
});

Help our community expand these hints and guides.