Learn how to publish your Cloudflare workers with Wrangler and submit data to its URL using the action
attribute on an HTML form.
Instructor: [0:01] open our terminal and publish our Worker by running, wrangler publish. You can see that our Worker is now available at this URL.
[0:10] If we head over to our Worker's dashboard, we can see that the Worker has been published. We head back to our components. We want to copy our Worker's URL and go to our form components and add it as an action. The action attribute specifies where to send the form data when a form is submitted. This is usually a URL.
[0:36] In our case, our action will be called Airtable Function. Then we can define this before the components and pasting our Worker URL. Remember that our Worker URL would only accept form submissions at /submit, so we want to add that to our URL. Then, if we commit this change and we say, Add a Table Function, then push to git.
[1:11] If we head back to our Pages workspace, you can see that a build has automatically been triggered. After this build is completed, we head over to our Pages sites and try to submit a form. Subject of my form would be Cloudflare Pages. We see, "Pages are awesome. Thank you all so much for building," and then we click Submit.
[1:44] We see that we have our stringified body returned to us. If we go to the form, you can see that you have form inputs populated to your fields.