Get product by id from database.
URL : /api/products/:id
URL parameter: id=[string]
where id
is mongoose object id syntax.
Method: GET
Code: 200 OK
Condition: If product with provided correctly id exists.
{
"__v": 0,
"_id": "6369523318c90dd1e14fd8b0",
"createdAt": "2022-11-07T18:45:07.229Z",
"name": "ball",
"price": 5,
"updatedAt": "2022-11-07T18:45:07.229Z"
}
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" }