Study : Express, RESTful API

Sever/Node.js 2018. 10. 24. 11:20
반응형

Study : Express, RESTful API

참고: https://velopert.com/294

구조잡기 : 라우터와 서버는 따로 만들것.

app : core.Express, Application상속 받음 

app.set : key, value 셋팅 하면 value 줌 

app.engine : 템플릿 엔진에 확장자파일을 연결해줌 

ex) app.engine('html', require('ejs').renderFile);


app.use 

express.static


RESTful API

REST(Representational State Transfer) 

소프트웨어 아키텍쳐중 하나의 형식 

HTTP프로토콜을 사용

서버의 정보에 접근및 변경을 가능하게 함 

GET: 조회

PUT: 생성및 업데이트

DELETE: 제거 

POST: 생성 



TypeError: Cannot read property 'password' of undefined

http://asfirstalways.tistory.com/60

body-parser 설치 할것.

https://www.npmjs.com/package/body-parser

app.use(require('body-parser'));추가 

req.body가 undefined 날때 

** 우선순위 주의 할것. : http://2dubbing.tistory.com/50

app.use(bodyParser.json());

router(app, require('fs'));


배열에서null값 제거 

http://code.i-harness.com/ko-kr/q/44ab0

ex)

var arr = [1,2,,3,,3,null,,0,,undefined,4,,4,,5,,6,,,,];

// (filter - JS 1.6 and above)

arr = arr.filter(function(n){ return n != undefined }); 

arr // [1, 2, 3, 3, 0, 4, 4, 5, 6]



반응형

'Sever > Node.js' 카테고리의 다른 글

jwt 스터디 1차  (0) 2019.01.02
jwt  (0) 2019.01.01
Node.js Passport login  (0) 2018.12.20
카페24 node.js + mysql + unity 연동 (CRUD, RestfulAPI)  (4) 2018.10.22
node.js + mysql + Unity 연동  (0) 2018.10.19
: