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:
@@ -272,7 +272,9 @@ export async function fetchDataInfo(
|
||||
* ```
|
||||
*/
|
||||
export async function fetcher<T>(url: string): Promise<T> {
|
||||
const fullUrl = url.startsWith('http') ? url : `${API_BASE_URL}${url.startsWith('/') ? url.slice(4) : url}`;
|
||||
// If it's already a full URL, use it directly
|
||||
// Otherwise, prepend the API_BASE_URL
|
||||
const fullUrl = url.startsWith('http') ? url : `${API_BASE_URL}${url.startsWith('/') ? url : `/${url}`}`;
|
||||
|
||||
const response = await fetch(fullUrl);
|
||||
return handleResponse<T>(response);
|
||||
|
||||
Reference in New Issue
Block a user