유니티3D 프로그래밍
Express Server Test (21.06.09) 본문
글로벌 설치 목록 확인
npm list -g
프로젝트 생성
express {project-name}
express learn-express
디렉터리로 들어와서
cd learn-express
//express 의존성 모듈 설치
npm install
//서버 시작
npm start
//확인
postman 설치
https://www.postman.com/downloads/
프로토콜 문서 확인
포스트맨으로 POST 방식으로 해당 URI에 데이터 전송 테스트
드롭 다운에서 POST선택
URL 입력
Body 체크 > Raw > JSON 선택
바디 부분에다가 데이터 입력
{
"nickname": "홍길동",
"email": "hong@gmail.com",
"password": 123456
}
Send 버튼 누르기
routes / users.js 수정
var express = require("express");
var router = express.Router();
/* GET users listing. */
router.get("/", function (req, res, next) {
res.send("respond with a resource");
});
router.post("/", (req, res, next) => {
console.log(req.body);
res.send("post, /users");
});
module.exports = router;
노드몬 글로벌 설치
npm i nodemon -g
package.json 열어서
"scripts": {
"start": "nodemon ./bin/www"
...
node로 되어 있는 부분 nodemon으로 수정
npm start하면 노드몬으로 실행됨
'Server > 수업내용' 카테고리의 다른 글
Express Server 회원 관리 (21.06.10) (0) | 2021.06.10 |
---|