Created
February 4, 2025 12:24
-
-
Save nataliaconde/b640258233fa1018f7240079ee86d542 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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