Skip to main content

Overview

Retrieve a paginated list of products from the Juadah bakery catalog. This endpoint supports infinite scrolling by using cursor-based pagination with the last_id parameter.

Endpoint

GET /api/products

Authentication

This endpoint requires authentication via cookie-based session.
last_id
number
The ID of the last product from the previous page. Provide this to fetch the next 50 products. For example, if you provide last_id=50, you’ll receive products 51-100.

Response

status
string
required
Response status. Returns "success" for successful requests.
data
object
required
Response data containing products and metadata.
meta
object
Pagination metadata.
lastProductId
number
The ID of the last product in the current response. Use this as last_id in the next request for pagination.
products
array
Array of product objects.
id
number
Unique product identifier.
name
string
Product name.
description
string | null
Product description. May be null if not provided.
price
number
Product price in rupiah.
images
string[] | null
Array of image URLs. May be null if no images are uploaded.

Example Request

Initial Request (First Page)

curl -X GET "https://juadah-backend.vercel.app/api/products" \
  -H "Cookie: accessToken=your-access-token"

Paginated Request (Next Page)

curl -X GET "https://juadah-backend.vercel.app/api/products?last_id=50" \
  -H "Cookie: accessToken=your-access-token"

Example Response

Success Response (200)

{
  "status": "success",
  "data": {
    "meta": {
      "lastProductId": 2
    },
    "products": [
      {
        "id": 1,
        "name": "Kue Bolu",
        "description": "Kue bolu paling enak",
        "price": 10000,
        "images": [
          "path/to/images.png",
          "path/to/images.png"
        ]
      },
      {
        "id": 2,
        "name": "Kue Kotak",
        "description": null,
        "price": 10000,
        "images": null
      }
    ]
  }
}

Error Response (404)

Returned when no products are found.
{
  "status": "fail",
  "errors": {
    "code": 404,
    "message": "resource you're looking for is not found"
  }
}

Implementation Notes

  • Each request returns up to 50 products
  • Products are returned in order by ID
  • Use the lastProductId from the response as the last_id parameter for the next request
  • If no last_id is provided, the first 50 products are returned
  • A 404 response indicates there are no more products to fetch