mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: save element content in DB
This commit is contained in:
parent
c9de9b4ff6
commit
4e966d9126
4 changed files with 92 additions and 21 deletions
|
|
@ -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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue