Commit 0644f25e authored by Chunchi Che's avatar Chunchi Che

add sync API

parent bb40099e
Pipeline #27781 passed with stages
in 8 minutes and 18 seconds
...@@ -2,4 +2,5 @@ export * from "./generate"; ...@@ -2,4 +2,5 @@ export * from "./generate";
export * from "./mget"; export * from "./mget";
export * from "./personalList"; export * from "./personalList";
export * from "./pull"; export * from "./pull";
export * from "./sync";
export * from "./upload"; export * from "./upload";
import { useConfig } from "@/config";
import { MdproResp } from "./schema";
import { handleHttps, mdproHeaders } from "./util";
const { mdproServer } = useConfig();
const API_PATH = "/api/mdpro3/sync/single";
export interface SyncReq {
userId: number;
token: string;
deckContributor: string;
deck: {
deckId: string;
deckName: string;
deckCase: number;
deckYdk: string;
isDelete: boolean;
};
}
export async function syncDeck(
req: SyncReq,
): Promise<MdproResp<boolean> | 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