03. route, res, req - seongjunhwang/clone_youtube GitHub Wiki

route

app.get("/", handleHome);

  • get, post ๋“ฑ ์ ์ ˆํ•œ ๋ฐฉ์‹์œผ๋กœ ํ˜ธ์ถœ
  • "/"์™€ ๊ฐ™์ด routeํ•  ์ฃผ์†Œ ์ž…๋ ฅ
  • ํ•ด๋‹น ์ฃผ์†Œ ์ ‘์† ์‹œ ํ˜ธ์ถœํ•  ํ•จ์ˆ˜ ์ž…๋ ฅ
function handleHome(req, res) {
    console.log(req);
    res.send("hello from home");
}
  • ํ•จ์ˆ˜ ํ˜ธ์ถœ ์‹œ req, res ์ธ์ž๊ฐ’์„ ๋ฐ›์Œ
  • req object์—์„œ ํ•„์š”ํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ์ถ”์ถœ
  • res ์—์„œ ํ•„์š”ํ•œ method ํ˜ธ์ถœ ๋ฐ ์‚ฌ์šฉ