feat: update forms instructions
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

closes: #1
This commit is contained in:
Aravinth Manivannan 2022-12-31 01:41:18 +05:30
parent 5c359c4090
commit e2a97f1059
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88

View file

@ -24,7 +24,11 @@ Forms can be added to websites with just the HTML code for it. For
instance: instance:
```html ```html
<form id="newsletter-form" method="POST"> <form
id="newsletter-form"
method="POST"
action="https://<librepages-endpoint>/?path=<current-path>&host=<current-host>"
>
<p> <p>
Interested in receiving latest news about our cool product? Sign Interested in receiving latest news about our cool product? Sign
up for you fantastic newsletter! up for you fantastic newsletter!
@ -60,7 +64,8 @@ JavaScript code:
const form = document.getElementById("newsletter-form"); const form = document.getElementById("newsletter-form");
async function handleSubmit() { async function handleSubmit() {
const url = window.location; const url =
"https://<librepages-endpoint>/api/v1/forms/submit?host=<current-host>&path=<current-path>";
const data = { const data = {
email: document.getElementById("email"), email: document.getElementById("email"),
}; };
@ -77,4 +82,5 @@ JavaScript code:
form.addEventListener("submit", handleSubmit); form.addEventListener("submit", handleSubmit);
</script> </script>
``` ```
> Note: the following snippet also demonstrates JSON form submission > Note: the following snippet also demonstrates JSON form submission