Node.js / NestJS

REST API Design

HTTP methods, status codes, RESTful principles, versioning, HATEOAS, pagination

20 면접 질문·
Junior
1

What is the appropriate HTTP method to retrieve a list of resources?

답변

The GET method is used to retrieve data without modifying server state. It is idempotent and safe, meaning it can be called multiple times without side effects. GET is the standard method for all read operations in a REST API.

2

Which HTTP method is idempotent and completely replaces an existing resource?

답변

PUT is idempotent and completely replaces the resource at the specified URL. Unlike PATCH which partially modifies, PUT requires sending the complete representation of the resource. Idempotence means calling PUT multiple times with the same data produces the same result.

3

What is the main difference between PUT and PATCH?

답변

PUT completely replaces the resource and requires sending all fields, even those that don't change. PATCH allows modifying only specified fields, making it more efficient for partial updates. For example, to modify only a user's email, PATCH is preferable.

4

Which HTTP status code should be returned after successfully creating a resource?

5

Which HTTP status code to use when the request is valid but authentication is required?

+17 면접 질문

다음 면접을 위해 Node.js / NestJS을 마스터하세요

모든 질문, flashcards, 기술 테스트, 코드 리뷰 연습, 면접 시뮬레이터에 접근하세요.

무료로 시작하기