Commit 506a733a authored by Chunchi Che's avatar Chunchi Che

add upload api

parent f49f97d4
Pipeline #27592 passed with stages
in 7 minutes and 55 seconds
export * from "./pull"; export * from "./pull";
export * from "./upload";
import { useConfig } from "@/config";
import { MdproDeck } from "./schema";
import { mdproHeaders } from "./util";
const { mdproServer } = useConfig();
const API_PATH = "api/mdpro3/deck/upload";
export interface UploadResp {
code: number;
message: string;
data: MdproDeck;
}
export async function uploadDeck(
req: MdproDeck,
): Promise<UploadResp | undefined> {
const myHeaders = mdproHeaders();
const resp = await fetch(`${mdproServer}/${API_PATH}`, {
method: "POST",
headers: myHeaders,
body: JSON.stringify(req),
});
if (!resp.ok) {
console.error(
`[Upload of Mdpro Decks] HTTPS error! status: ${resp.status}`,
);
return undefined;
} else {
return await resp.json();
}
}
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