게임 웹 프로그래밍/node.js
06/11 node.js 리퀘스트의 params, query확인
박준희
2021. 6. 11. 14:10
next함수
next('route')
리퀘스트의 params, query확인
:id
req.params.id로 조회 가능
:type이면 req.params.type으로 조회 가능
const express = require("express");
const router = express.Router();
router.get("/:id", (req, res, next) => {
console.log(req.params);
console.log(req.query);
res.send('검색');
});
module.exports = router;
send
문자열, html코드, json데이터를 전송가능
sendFile
파일을 응답으로 보냄
우리가 http상태코드를 보낼 수 있음
res.status(404).send("Not Found")