danmu-sim/lib/actions/live.ts

27 lines
667 B
TypeScript
Raw Normal View History

2024-04-07 03:23:34 +08:00
"use server";
import { cookies } from "next/headers";
export async function listLives(): Promise<any[]> {
const token = cookies().get("token");
const params = new URLSearchParams();
params.append("pageSize", "99999");
const lives = await fetch(
"https://tachy.daoyoucloud.com/api/lives:list?" + params.toString(),
{
method: "GET",
headers: {
"X-App": "danmu-sim",
"X-Authenticator": "basic",
authorization: "Bearer " + token?.value,
"content-type": "application/json",
},
next: {
tags: ["lives"],
},
}
);
const result = await lives.json();
return result?.data ?? [];
}