APIs 와 Node

XCC629·2022년 3월 14일
0

backend

목록 보기
1/8
post-thumbnail

UI와 API

UI는 사용자가 마주하는 부분, API는 개발자가 다루는 부분을 말한다. 사용자는 화면을 보고 마우스 등으로 조작하여 브라우저와 마주하지만, 개발자는 어떤 기능을 하는 함수를 작성하여 브라우저를 마주한다.

http모듈과 express로 서버 생성 차이

http모듈로 서버를 생성하면 server가 서버를 여는 역할과 res와 req를 받는 역할을 모두 수행한다. express로 하면 이 역할을 분리할 수 있어서 유지보수가 편리해진다.

  • 이외의 차이가 존재하는지 공부가 필요하다.(03/14)

res.end(), res.send(), res.json()

클라이언트가 서버에게 요청(request)을 보내면 응답(response)를 보내준다. 응답에는 위 가지를 쓸 수 있다.
res.send(): 기본 값이다.
res.json(): json형식으로 보낸다.
res.end(): 응답으로 보낼 값이 없을 때 쓴다.

status 코드

HTTP 요청처리에 대해 알려주는 코드입니다.

1--번: 요청받았고 계속하겠다.
100 Continue
101 Switching Protocol
102 Processing
103 Early Hints

2--번: 성공!
200 OK
201 Created
202 Accepted
203 Non-Authoritative Information
204 No Content
205 Reset Content
206 Partial Content
207 Multi-Status
208 Multi-Status
226 IM Used (HTTP Delta encoding)

3--번: 추가작업 필요
300 Multiple Choice
301 Moved Permanently
302 Found
303 See Other
304 Not Modified
305 Use Proxy
307 Temporary Redirect
308 Permanent Redirect

4--번: 클라이언트 오류
400 Bad Request
401 Unauthorized
402 Payment Required
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable
407 Proxy Authentication Required
408 Request Timeout
409 Conflict
410 Gone
411 Length Required
412 Precondition Failed
413 Payload Too Large
414 URI Too Long
415 Unsupported Media Type
416 Requested Range Not Satisfiable
417 Expectation Failed
421 Misdirected Request
422 Unprocessable Entity
423 Locked
424 Failed Dependency
426 Upgrade Required
428 Precondition Required
429 Too Many Requests
431 Request Header Fields Too Large
451 Unavailable For Legal Reasons

5--번: 서버오류
500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway Timeout
505 HTTP Version Not Supported
506 Variant Also Negotiates
507 Insufficient Storage
508 Loop Detected
510 Not Extended
511 Network Authentication Required


출처
HTTP 상태 코드

profile
프론트엔드 개발자

0개의 댓글