Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/ecommerce-delivery-frontend/llms.txt

Use this file to discover all available pages before exploring further.

All primary data-fetching in Ecommerce Delivery is performed with the browser’s native fetch API — not Axios. Axios is registered as a Quasar boot plugin (src/boot/axios.js) and is available as this.$axios and this.$api on the Vue global properties for convenience, but the actual page and component code issues requests directly with fetch. This keeps API calls explicit and avoids a secondary abstraction layer on top of the standard Web API.

Base URL

Every API call is prefixed with process.env.API_SERVER, which is injected from a .env file at build time via the dotenv integration configured in quasar.config.js:
// quasar.config.js (build section)
env: require('dotenv').config().parsed,
At call sites the pattern is always:
fetch(process.env.API_SERVER + '/api/product/list-product/1/10', { ... })
Define API_SERVER in your .env file at the project root:
API_SERVER=https://your-backend.example.com

Standard request pattern

Every API call follows the same structure: POST method, cors mode, a JSON Content-Type header, a Bearer token from the current session, and a JSON-serialised body.
const res = await fetch(
  process.env.API_SERVER + '/api/product/list-product/1/10',
  {
    method: 'POST',
    mode: 'cors',
    headers: {
      'Content-Type': 'application/json',
      Authorization: `Bearer ${sessionUser.token}`,
    },
    body: JSON.stringify({ title: '' }),
  }
);
const data = await res.json();
The sessionUser object is obtained at the top of each component’s setup() by calling getDataUser() from src/tools/User.js, which reads both the serialised user and the raw token from localStorage.

Authentication headers

Two authorization schemes appear in the source depending on the endpoint:
SchemeHeader valueUsed for
BearerAuthorization: Bearer <token>Products, notifications, most endpoints
BasicAuthorization: Basic <token>Some sales endpoints
The inconsistency between Bearer and Basic reflects the backend’s routing conventions. Check the specific endpoint in the reference table below before sending a request to confirm which scheme it expects.

Standard response shape

All API responses share a common JSON envelope:
{
  "status": true,
  "message": "Operation successful",
  "data": [...],
  "pagination": {
    "pag": 1,
    "perpage": 10,
    "pags": 5,
    "cant": 50
  }
}
FieldTypeDescription
statusbooleantrue on success, false on application-level failure
messagestringHuman-readable result message
dataarray | objectPayload — array for lists, object for single-resource responses
paginationobjectPresent on paginated endpoints; omitted for single-resource calls
pagination.pagnumberCurrent page number
pagination.perpagenumberItems per page requested
pagination.pagsnumberTotal number of pages
pagination.cantnumberTotal item count across all pages

Error handling

Immediately after parsing every API response, ValidateSession from src/tools/User.js is called with the response object and the current router instance:
// src/tools/User.js
const ValidateSession = (res, router) => {
  if (res.code == "403" || res.code == 403 || res.code == "401" || res.code == 401) {
    router.push({ path: "/login" });
    localStorage.clear();
    return false;
  }
  return true;
};
If the response carries a 401 (Unauthorised) or 403 (Forbidden) code, the function:
1

Redirects to /login

Calls router.push({ path: '/login' }) to send the user back to the sign-in screen immediately.
2

Clears localStorage

Calls localStorage.clear() to remove the token, serialised user, and cart state so no stale credentials remain.
3

Returns false

Returns false so the caller can short-circuit any further processing of the response payload.
A typical guarded call site looks like:
const res = await fetch(process.env.API_SERVER + '/api/sale/all-list/1/10', {
  method: 'POST',
  mode: 'cors',
  headers: {
    'Content-Type': 'application/json',
    Authorization: `Basic ${sessionUser.token}`,
  },
  body: JSON.stringify({}),
});
const data = await res.json();
if (!ValidateSession(data, router)) return;

Pagination

All list endpoints accept the current page and page size directly in the URL path:
POST /api/product/list-product/:pag/:perpage
Pass them as path segments when constructing the URL:
const pag = 1;
const perpage = 10;
const res = await fetch(
  `${process.env.API_SERVER}/api/product/list-product/${pag}/${perpage}`,
  { ... }
);
The response pagination object tells you the total number of pages (pags) and the total item count (cant) so your component can render correct page controls.

Full API endpoint reference

All endpoints use the POST HTTP method — even listing and read operations. This is the backend’s global convention; do not use GET for any of these routes.
EndpointPurpose
POST /api/user/loginAuthenticate user and receive a JWT token
POST /api/user/createRegister a new user account
POST /api/user/list-members/:pag/:perpageList all registered users (admin only)
POST /api/user/update-role/:idUpdate a user’s role (admin only)
POST /api/product/list-product/:pag/:perpagePaginated product listing
POST /api/product/search-product/:querySearch products by name
POST /api/product/get-product-type-prd/:type/:pag/:perpageFilter products by shirt type
POST /api/product/list-id/:idRetrieve a single product by ID
POST /api/product/createCreate a new product (admin, multipart form data)
POST /api/product/update/:idUpdate an existing product (admin, multipart form data)
POST /api/sale/pay/:productIdPlace an order for a product
POST /api/sale/all-list/:pag/:perpageList all sales across all users (admin)
POST /api/sale/list-sale/:pag/:perpageList the current user’s own orders
POST /api/sale/get-search/:querySearch across all sales records (admin)
POST /api/sale/status-delivery/:idSaleUpdate the delivery status of a sale
POST /api/sale/export-list-sale-xlsxExport the full sales list as an Excel file
POST /api/notifications/list/:pag/:perpagePaginated list of notifications for the current user
POST /api/notification/register-tokenRegister an FCM device token for push notifications

Axios boot plugin

Although fetch is used for all API work, src/boot/axios.js registers Axios as a Vue global for any future use:
// src/boot/axios.js
import { boot } from 'quasar/wrappers'
import axios from 'axios'

const api = axios.create({ baseURL: 'https://api.example.com' })

export default boot(({ app }) => {
  app.config.globalProperties.$axios = axios
  app.config.globalProperties.$api = api
})

export { api }
The boot entry in quasar.config.js ensures this runs before the app mounts:
// quasar.config.js
boot: ['axios'],
this.$axios gives access to the raw Axios singleton; this.$api gives access to the pre-configured instance with a base URL. Both are available inside Vue Options API components without any additional imports.

Build docs developers (and LLMs) love