Orders
Get All Order Data

Get All Order Data

Fetch All customer Order data

Endpoint

Base URL
http://localhost:8080
Method and Endpoint
GET /api/users/current/orders
Headers
Authorization: Bearer access_token

Responses

You will get responses like this:

200 (success)

Response Body
{
  "message": "Successfully Fetch all Orders",
  "result": [
    {
      "id": "60c72b2f9b1e8b3d4c8d2c6e",
      "order_id": "ORD123456789",
      "email": "user@example.com",
      "order_date": "2024-05-25T15:45:12.370Z",
      "updated_at": "2024-05-30T10:20:30.370Z",
      "total_price": 199.98,
      "address_shipping": {
        "street": "123 Elm Street",
        "city": "San Francisco",
        "state": "CA",
        "postal_code": "94101",
        "country": "USA"
      },
      "payment": {
        "status": "Paid",
        "transaction_id": "TX123456789",
        "payment_method": "Credit Card"
      },
      "items": [
        {
          "product_id": "WH123456",
          "product_name": "Wireless Headphones",
          "product_image": [
            "https://example.com/images/product1.jpg",
            "https://example.com/images/product2.jpg"
          ],
          "store_id": "ST123456",
          "order_status": "Shipped",
          "quantity": 1,
          "price": 99.99
        },
        {
          "product_id": "SW789012",
          "product_name": "Smartwatch",
          "product_image": [
            "https://example.com/images/product3.jpg",
            "https://example.com/images/product4.jpg"
          ],
          "store_id": "ST789012",
          "order_status": "Processing",
          "quantity": 1,
          "price": 99.99
        }
      ]
    },
    {
      "id": "60d72b2f9b1e8b3d4c8d2c6f",
      "order_id": "ORD987654321",
      "email": "user2@example.com",
      "order_date": "2024-05-28T10:30:00.370Z",
      "updated_at": "2024-05-30T11:00:30.370Z",
      "total_price": 299.97,
      "address_shipping": {
        "street": "456 Oak Avenue",
        "city": "New York",
        "state": "NY",
        "postal_code": "10001",
        "country": "USA"
      },
      "payment": {
        "status": "Pending",
        "transaction_id": "TX987654321",
        "payment_method": "PayPal"
      },
      "items": [
        {
          "product_id": "LS345678",
          "product_name": "Laptop Stand",
          "product_image": ["https://example.com/images/product5.jpg"],
          "store_id": "ST345678",
          "order_status": "Pending",
          "quantity": 1,
          "price": 39.99
        },
        {
          "product_id": "KB567890",
          "product_name": "Mechanical Keyboard",
          "product_image": ["https://example.com/images/product6.jpg"],
          "store_id": "ST567890",
          "order_status": "Pending",
          "quantity": 1,
          "price": 59.99
        },
        {
          "product_id": "MS098765",
          "product_name": "Wireless Mouse",
          "product_image": ["https://example.com/images/product7.jpg"],
          "store_id": "ST098765",
          "order_status": "Pending",
          "quantity": 2,
          "price": 99.99
        }
      ]
    }
  ]
}

401 (unauthorized)

Response Body
{
  "error": "Invalid authorization header"
}

401 (unauthorized - expire token)

Response Body
{
  "error": "token is expired: token is expired by 2m19s"
}

500 (server error)

Response Body
{
  "error": "Internal server error"
}

500 (server error - failed)

If query to database get troble while get the user data

Response Body
{
  "error": "failed to find user"
}

500 (server error - failed)

If query to database get troble while get the order data

Response Body
{
  "error": "failed to get all orders"
}