fetch('../api/reports_api.php?event_id=1&type=all')
.then(response => response.json())
.then(data => {
console.log('API Response:', data);
console.table(data.reports);
console.log('Statistics:', data.stats);
})
.catch(error => console.error('Error:', error));
fetch('../api/reports_api.php?event_id=1&type=start_list')
.then(response => response.json())
.then(data => {
console.log('Start Lists:', data.grouped_reports.start_list);
data.reports.forEach(report => {
console.log(`${report.name}: ${report.urls.pdf}`);
});
})
.catch(error => console.error('Error:', error));
fetch('../api/reports_api.php?event_id=1&type=summary_table')
.then(response => response.json())
.then(data => {
console.log('Summary Tables:', data.grouped_reports.summary_table);
data.reports.forEach(report => {
console.log(`${report.name} - Heat: ${report.heat_badge}`);
console.log('URLs:', report.urls);
});
})
.catch(error => console.error('Error:', error));
// Change the event_id value below
const eventId = 3; // Change this to your event ID
const filterType = 'all'; // or 'start_list' or 'summary_table'
fetch(`../api/reports_api.php?event_id=${eventId}&type=${filterType}`)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
return response.json();
})
.then(data => {
console.log('=== API RESPONSE ===');
console.log('Success:', data.success);
console.log('Event ID:', data.event_id);
console.log('Filter Type:', data.filter_type);
console.log('Statistics:', data.stats);
console.log('=== REPORTS ===');
console.table(data.reports);
console.log('=== GROUPED REPORTS ===');
console.log('Start Lists:', data.grouped_reports.start_list);
console.log('Summary Tables:', data.grouped_reports.summary_table);
})
.catch(error => {
console.error('=== ERROR ===');
console.error('Error details:', error);
});
curl "http://localhost/stylescore2025/htdocs/v2/api/reports_api.php?event_id=1"The API now includes proper CORS headers to allow cross-origin requests:
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization