File size: 821 Bytes
c7fb8cf
 
 
 
 
a087ed4
c7fb8cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
 * api.js
 * Handles all communication with the FastAPI backend.
 */

const API_BASE = import.meta.env.VITE_API_URL ||
                 (import.meta.env.PROD ? '/api' : 'http://localhost:8000/api');

/**
 * Sends resume files and job details to the backend for screening.
 * @param {FormData} formData - All form fields + files
 * @returns {Promise<Object>} Ranked candidate results
 */
export async function analyzeResumes(formData) {
  const response = await fetch(`${API_BASE}/analyze`, {
    method: 'POST',
    body: formData,
    // Do NOT set Content-Type – the browser sets it with the boundary for multipart
  });

  if (!response.ok) {
    const errData = await response.json().catch(() => ({}));
    throw new Error(errData.detail || `Server error: ${response.status}`);
  }

  return response.json();
}