Skip to content

Instantly share code, notes, and snippets.

@nataliaconde
Created February 4, 2025 12:24
Show Gist options
  • Save nataliaconde/b640258233fa1018f7240079ee86d542 to your computer and use it in GitHub Desktop.
Save nataliaconde/b640258233fa1018f7240079ee86d542 to your computer and use it in GitHub Desktop.
<!-- journal.astro -->
<script>
import Parse from "parse/dist/parse.min.js";
Parse.initialize(APPLICATION_ID, JAVASCRIPT_KEY);
Parse.serverURL = "<https://parseapi.back4app.com/>";
const title = document.querySelector('input.title') as HTMLInputElement;
const body = document.querySelector('textarea.body') as HTMLTextAreaElement;
const button = document.querySelector('button.log');
const addJournal = async (event) => {
event.preventDefault();
try {
const Journal = Parse.Object.extend("Journal");
const journal = new Journal();
journal.set("title", title.value);
journal.set("content", body.value);
await journal.save();
console.log('Text added');
} catch (error) {
console.log(error);
}
};
button.addEventListener('click', addJournal);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment