From 9383a2fb09ffb60cfe63683106945bd688affa59 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Wed, 1 Jun 2022 21:13:43 +0200 Subject: feat: Initial commit after clean slate --- src/wwwroot/scripts/api/documents-api.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/wwwroot/scripts/api/documents-api.ts (limited to 'src/wwwroot/scripts/api/documents-api.ts') diff --git a/src/wwwroot/scripts/api/documents-api.ts b/src/wwwroot/scripts/api/documents-api.ts new file mode 100644 index 0000000..f458f6c --- /dev/null +++ b/src/wwwroot/scripts/api/documents-api.ts @@ -0,0 +1,24 @@ +export function uploadDocumentImages(files: Array): Promise { + if (files.length <= 0) throw new Error("files.length was " + files.length); + const data = new FormData(); + for (const file of files) + data.append("files", file); + + return fetch("/api/documents/upload-images", { + method: "post", + body: data + }); +} + +export function getDocument(documentType: string) { + return fetch("/api/documents/" + documentType); +} + +export function setDocument(documentType: string, content: string) { + const fd = new FormData(); + fd.append("content", content); + return fetch("/api/documents/" + documentType, { + method: "post", + body: fd, + }); +} \ No newline at end of file -- cgit v1.3