mirror of
https://github.com/Radiquum/AniX.git
synced 2025-05-23 05:09:38 +05:00
feat: add history api and page
This commit is contained in:
parent
e73b214045
commit
eb620c0b1d
5 changed files with 186 additions and 22 deletions
19
app/api/history/route.js
Normal file
19
app/api/history/route.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { NextResponse } from "next/server";
|
||||
import { fetchDataViaGet } from "../utils";
|
||||
import { ENDPOINTS } from "../config";
|
||||
|
||||
export async function GET(request) {
|
||||
const page = parseInt(request.nextUrl.searchParams.get(["page"])) || 0;
|
||||
const token = request.nextUrl.searchParams.get(["token"]) || null;
|
||||
const sortName = request.nextUrl.searchParams.get(["sort"]) || "adding_descending";
|
||||
|
||||
if (!token || token == "null") {
|
||||
return NextResponse.json({ message: "No token provided" }, { status: 403 });
|
||||
}
|
||||
|
||||
let url = new URL(`${ENDPOINTS.user.history}/${page}`);
|
||||
url.searchParams.set("token", token);
|
||||
|
||||
const response = await fetchDataViaGet(url.toString());
|
||||
return NextResponse.json(response);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue