전체 글
-
res.send(), res.json(), res.end()Javascript/Node.js and Express 2021. 7. 27. 02:05
결론 부터 말하자면 send()와 json()은 별차이가 없지만 차이가 있다. json()은 json화 해서 보내주고 결국은 마지막에 send()으로 마무리한다. JSON은 String, Number, Object, Array, Boolean, Null을 지원하며 Function, Date, Undefined 등과 같은 타입은 지원하지 않는다. res.send()는 Buffer , String, Object 그리고 Array를 body로 받을수 있다. .end()는 아무것도 하지 않고 프로세스를 종료해 버리는데 보통 status(404)와 같은 에러를 띄어주고 끝내버리는 경우에 쓰인다. ex) res.status(404).end()
-
-
-
-
AWS 배포 및 몽고db연결Javascript/Node.js and Express 2021. 7. 22. 14:35
EC2 배포 (몽고db) //터미널에서 EC2 접속 sudo chmod 400 @키페어 ssh -i @키페어 ubuntu@AWS아이피 //Node.js 설치 curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - //Node.js 설치 sudo apt-get install -y nodejs //몽고db설치 wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add - echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo te..