Commit 59e223fe authored by Chunchi Che's avatar Chunchi Che

add updatePublic API

parent 0644f25e
Pipeline #27784 passed with stages
in 7 minutes and 50 seconds
......@@ -3,4 +3,5 @@ export * from "./mget";
export * from "./personalList";
export * from "./pull";
export * from "./sync";
export * from "./updatePulibc";
export * from "./upload";
import { useConfig } from "@/config";
import { MdproResp } from "./schema";
import { handleHttps, mdproHeaders } from "./util";
const { mdproServer } = useConfig();
const API_PATH = "/api/mdpro3/deck/public";
export interface UpdatePublicReq {
userId: number;
token: string;
deckId: string;
isPublic: boolean;
}
export async function updatePublic(
req: UpdatePublicReq,
): Promise<MdproResp<void> | undefined> {
const myHeaders = mdproHeaders();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("token", req.token);
const resp = await fetch(`${mdproServer}/${API_PATH}`, {
method: "POST",
headers: myHeaders,
body: JSON.stringify(req),
redirect: "follow",
});
return await handleHttps(resp, API_PATH);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment