🛒 Ecommerce
Create product
The API enables an authenticated user with the role of ADMIN to create a product by providing various details in the request body using form data.
The required fields for creating a product includes:
- name
- description
- price
- stock quantity
- category (referenced by the category ID),
- mainImage (representing the main product image),
- subImages (up to 4 additional images that can be viewed in a carousel on the frontend).
By submitting this information via form data, the API allows administrators to efficiently add new products to the system, ensuring accurate and comprehensive product listings for users.
post/ecommerce/products
Response
Create product
Example response
{
"data": {
"_id": "647b9a640c656eb8be498f45",
"category": "6478e1c2b3b51f6d24e0aa5b",
"createdAt": "2023-06-03T19:54:12.026Z",
"description": "Product 2 description a long descriptio2",
"mainImage": "http://localhost:8080/images/933e65fe78b096f07ac7fa60caf07d13",
"name": "Product 2",
"owner": "647b8582f3c8e42f3200d26a",
"price": 4000,
"stock": 10,
"subImages": [
"http://localhost:8080/images/1983c8803bb472811a674635b40e2cdf",
"http://localhost:8080/images/3422ec41808129eb1329ddb11f289690"
],
"updatedAt": "2023-06-03T19:54:12.026Z"
},
"message": "Product created successfully",
"statusCode": 201,
"success": true
}