Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/RespondeIA-APP/front/llms.txt

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

The authService.register method is the frontend service layer that handles user registration. This method calls the backend /api/register endpoint to create new user accounts.
This documentation covers the frontend service layer from the RespondeIA frontend repository. The backend API endpoints are hosted separately.

Source Code

From modules/auth/services/auth.service.ts:
export const authService = {
  // ...
  register: async (data: any) => {
    const res = await fetch('/api/register', {
      method: 'POST',
      body: JSON.stringify(data),
    });
    return res.json();
  }
};

Parameters

data
object
required
Registration data object containing user information.

Returns

Returns a Promise that resolves to the parsed JSON response from the backend API.

Usage Example

From modules/auth/components/RegisterForm.tsx:
const RegisterForm = () => {
  const [formData, setFormData] = useState({
    firstName: "",
    lastName: "",
    email: "",
    password: ""
  });

  const handleSubmit = async (e: React.FormEvent) => {
    e.preventDefault();
    try {
      const result = await authService.register(formData);
      console.log('Registration successful', result);
      // Redirect to login or dashboard
    } catch (error) {
      console.error('Registration failed', error);
    }
  };

  return (
    <form onSubmit={handleSubmit}>
      <Input 
        value={formData.firstName}
        onChange={(e) => setFormData({...formData, firstName: e.target.value})}
        placeholder="Juan"
      />
      <Input 
        value={formData.lastName}
        onChange={(e) => setFormData({...formData, lastName: e.target.value})}
        placeholder="Pérez"
      />
      <Input 
        type="email"
        value={formData.email}
        onChange={(e) => setFormData({...formData, email: e.target.value})}
        placeholder="nombre@empresa.com"
      />
      <Input 
        type="password"
        value={formData.password}
        onChange={(e) => setFormData({...formData, password: e.target.value})}
        placeholder="Mínimo 8 caracteres"
      />
      <Button type="submit">Registrarse</Button>
    </form>
  );
};

authService.login

Authenticate users after registration

RegisterForm Component

UI component using the register service

useAuthStore

Zustand store for authentication state

Authentication Guide

Complete authentication workflow guide