mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-04 02:39:14 +02:00
39 lines
887 B
TypeScript
39 lines
887 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;
|
|
}
|