mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-05 07:44:38 +00:00
21 lines
737 B
JavaScript
21 lines
737 B
JavaScript
import { NextResponse } from "next/server";
|
|
import { fetchDataViaPost } from "../utils";
|
|
import { ENDPOINTS } from "../config";
|
|
|
|
export async function GET(request) {
|
|
const page = parseInt(request.nextUrl.searchParams.get(["page"])) || 0;
|
|
const query = request.nextUrl.searchParams.get(["q"]) || null;
|
|
const token = request.nextUrl.searchParams.get(["token"]) || null;
|
|
let url = new URL(`${ENDPOINTS.search}/${page}`);
|
|
if (token) {
|
|
url.searchParams.set("token", token);
|
|
}
|
|
const data = { query, searchBy: 0 };
|
|
|
|
const response = await fetchDataViaPost(url.toString(), data, true);
|
|
if (!response) {
|
|
return NextResponse.json({ message: "Bad request" }, { status: 400 });
|
|
}
|
|
|
|
return NextResponse.json(response);
|
|
}
|