mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender-pwa.git
synced 2026-01-17 18:12:25 +01:00
41 lines
891 B
TypeScript
41 lines
891 B
TypeScript
import { Module } from "../model/module.ts";
|
|
|
|
export async function createIndividualFeed(modules: Module[]): Promise<string> {
|
|
let token = "";
|
|
|
|
await fetch("/api/createFeed", {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify(modules),
|
|
})
|
|
.then((response) => {
|
|
return response.json();
|
|
})
|
|
.then((response) => {
|
|
token = response;
|
|
});
|
|
return token;
|
|
}
|
|
|
|
export async function saveIndividualFeed(
|
|
token: string,
|
|
modules: Module[],
|
|
): Promise<string> {
|
|
await fetch("/api/collections/feeds/records/" + token, {
|
|
method: "PATCH",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: '{"modules":' + JSON.stringify(modules) + "}",
|
|
})
|
|
.then((response) => {
|
|
return response.json();
|
|
})
|
|
.then((response) => {
|
|
token = response;
|
|
});
|
|
return token;
|
|
}
|