Files
Vadella, Anna d4777b5e72 Updated page.tsx
Updated home page, still using preprocessed_data.xlsx because using updated_datav2.xlsx basically crashes the frontend rn lol :p
2026-04-01 13:02:29 -04:00

15 lines
930 B
TypeScript

// api for routing to movie slug based on user's search
import movies from "../../../../movies.json"; // import JSON dataset containing all movies
export async function GET(req: Request) {
const {searchParams} = new URL(req.url); // gets request URL w/ query parameters
const query = searchParams.get("q")?.toLowerCase() || "";
const results = movies // only return movies that include search term in their title
.filter((m) => m.title.toLowerCase().includes(query)) // filter searches dataset for titles containing query
.slice(0, 10); // limit to top 10 results
return new Response(JSON.stringify(results), {
headers: {"Content-Type": "application/json"}, // returns JSON array of movie objects
});
}