Skip to content

Latest commit

 

History

History
48 lines (31 loc) · 788 Bytes

getById.md

File metadata and controls

48 lines (31 loc) · 788 Bytes

Get product by id

Description

Get product by id from database.

URL : /api/products/:id

URL parameter: id=[string] where id is mongoose object id syntax.

Method: GET

Success Response

Code: 200 OK

Condition: If product with provided correctly id exists.

Context example

{
  "__v": 0,
  "_id": "6369523318c90dd1e14fd8b0",
  "createdAt": "2022-11-07T18:45:07.229Z",
  "name": "ball",
  "price": 5,
  "updatedAt": "2022-11-07T18:45:07.229Z"
}

Error Response

Code: 400 BAD REQUEST

Condition: If provided id has incorrect type.

{ "id": "Provided id is incorrect" }

Code: 400 BAD REQUEST

Condition: If product with provided id doesn't exist.

{ "id": "Product with provided id doesn't exist" }