vite-project v0.0.0


services/AuthService

Axios-based client for the AILA backend API.

Remarks

Axios client for the AILA backend. Encapsulates all HTTP calls:

  • Login, logout, register, verify

  • Conversations (create, fetch, rename)

  • Messages (create, fetch)

  • Feedback submission

  • Request endpoint (chat)

Responsibilities

  • Encapsulates all HTTP calls (login, register, verify, conversations, messages, feedback, logout).

  • Normalizes error handling and return shapes for the frontend.

Conventions

  • All requests use withCredentials: true to send HttpOnly cookies (JWT).

  • On Axios errors, functions return { error_message: string } where applicable.

  • Functions that don't need a payload from the server return boolean | undefined.

  • Functions that must return data bubble it through .data as typed.

Conventions:

  • All requests → withCredentials: true (send cookies)

  • Errors → return { error_message } where possible

  • Functions without data → return boolean | undefined

  • Functions with data → bubble .data

Example

import { loginAPI } from '../services/AuthService';
const res = await loginAPI('alice', 's3cret');
if ('user_details' in res) {
console.log(res.user_details.username);
}

Functions