fix: add error handling and use existing utility
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,8 +3,15 @@
|
||||
|
||||
import { useState } from 'react';
|
||||
import useSWR from 'swr';
|
||||
import { formatVersion } from '@/lib/fs-utils';
|
||||
|
||||
const fetcher = (url: string) => fetch(url).then((res) => res.json());
|
||||
const fetcher = async (url: string) => {
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) {
|
||||
throw new Error(`HTTP error: ${res.status}`);
|
||||
}
|
||||
return res.json();
|
||||
};
|
||||
|
||||
interface SearchFormProps {
|
||||
onSearch: (project: string, version: string, commitId: string) => void;
|
||||
@@ -81,7 +88,7 @@ export default function SearchForm({ onSearch }: SearchFormProps) {
|
||||
) : (
|
||||
versions?.map((version: string) => (
|
||||
<option key={version} value={version}>
|
||||
{version.replace('_', '.')}
|
||||
{formatVersion(version)}
|
||||
</option>
|
||||
))
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user