Skip to content

Commit

Permalink
Implement form handler
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Nov 14, 2023
1 parent 06708d2 commit 3f973d1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/realtime-compiler/resources/live-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,21 @@ function initLiveEdit() {
}

function handleFormSubmit(event, editor) {
//
event.preventDefault();

fetch('/_hyde/live-edit', {
method: "POST",
body: new FormData(event.target),
headers: new Headers({
"Accept": "application/json",
}),
}).then(async response => {
if (response.ok) {
window.location.reload();
} else {
alert(`Error saving content: ${response.status} ${response.statusText}\n${JSON.parse(await response.text()).error ?? 'Unknown error'}`);
}
});
}

const article = getArticle();
Expand Down

0 comments on commit 3f973d1

Please sign in to comment.