feat: save element content in DB

This commit is contained in:
swve 2022-11-13 19:50:08 +01:00
parent c9de9b4ff6
commit 4e966d9126
4 changed files with 92 additions and 21 deletions

View file

@ -23,5 +23,37 @@ export async function createElement(data: any, chapter_id: any) {
console.log("result", result);
return result;
}
export async function getElement(element_id: any) {
const requestOptions: any = {
method: "GET",
redirect: "follow",
credentials: "include",
};
const result: any = await fetch(`${getAPIUrl()}elements/${element_id}`, requestOptions)
.then((result) => result.json())
.catch((error) => console.log("error", error));
return result;
}
export async function updateElement(data: any, element_id: any) {
const HeadersConfig = new Headers({ "Content-Type": "application/json" });
const requestOptions: any = {
method: "PUT",
headers: HeadersConfig,
redirect: "follow",
credentials: "include",
body: JSON.stringify(data),
};
const result: any = await fetch(`${getAPIUrl()}elements/${element_id}`, requestOptions)
.then((result) => result.json())
.catch((error) => console.log("error", error));
return result;
}