Routing
app.get(path,callback function)
const express = require("express");
const app = express();
let port = 3000;
app.listen(port, () => {
console.log(`app is listening on port ${port}`);
});
app.get("/", (req, res) => {
res.send("you searched for root path");
});
app.get("/orange", (req, res) => {
res.send("you searched for orange path");
});
app.get("/apple", (req, res) => {
res.send("you searched for apple path");
});
app.get("*", (req, res) => {
res.send("This path doesn't exist");
});
app.post("/", (req, res) => {
res.send("you sent a post request");
});





Comments
Post a Comment