Fix: Use centralized API functions instead of manual URL construction
- ComparisonView now uses fetchComparison from lib/api - SchoolSearchModal now uses fetchSchools from lib/api - Fixed bug in fetcher function that incorrectly sliced URLs (url.slice(4) was removing '/com' from '/compare') This fixes the malformed URL issue where '/api/compare' became '/apipare'. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import { SchoolSearchModal } from './SchoolSearchModal';
|
||||
import { EmptyState } from './EmptyState';
|
||||
import type { ComparisonData, MetricDefinition } from '@/lib/types';
|
||||
import { formatPercentage, formatProgress } from '@/lib/utils';
|
||||
import { fetchComparison } from '@/lib/api';
|
||||
import styles from './ComparisonView.module.css';
|
||||
|
||||
interface ComparisonViewProps {
|
||||
@@ -55,13 +56,8 @@ export function ComparisonView({
|
||||
|
||||
// Fetch comparison data
|
||||
if (selectedSchools.length > 0) {
|
||||
const apiBaseUrl = process.env.NEXT_PUBLIC_API_URL || '/api';
|
||||
console.log('Fetching comparison data for URNs:', urns);
|
||||
fetch(`${apiBaseUrl}/compare?urns=${urns}`)
|
||||
.then((res) => {
|
||||
console.log('Comparison API response status:', res.status);
|
||||
return res.json();
|
||||
})
|
||||
fetchComparison(urns, { cache: 'no-store' })
|
||||
.then((data) => {
|
||||
console.log('Comparison data received:', data);
|
||||
setComparisonData(data.comparison);
|
||||
|
||||
Reference in New Issue
Block a user