Spaces:
Runtime error
Runtime error
| import { getAnnotations } from '../../../utils/storage.js'; | |
| export async function GET(request) { | |
| try { | |
| const { searchParams } = new URL(request.url); | |
| const docIndex = searchParams.get('document_index'); | |
| const filter = docIndex !== null ? parseInt(docIndex, 10) : null; | |
| const annotations = await getAnnotations(filter); | |
| return new Response(JSON.stringify(annotations), { | |
| status: 200, | |
| headers: { 'Content-Type': 'application/json' } | |
| }); | |
| } catch (error) { | |
| console.error("Error fetching annotations:", error); | |
| return new Response( | |
| JSON.stringify({ error: "Failed to fetch annotations" }), | |
| { status: 500, headers: { 'Content-Type': 'application/json' } } | |
| ); | |
| } | |
| } | |