⚠️ This lesson is retired and might contain outdated information.

Publish a Cloudflare Worker and Submit Data with an HTML Form

Obinna Ekwuno
InstructorObinna Ekwuno
Share this video with your friends

Social Share Links

Send Tweet
Published 2 years ago
Updated 2 years ago

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.

egghead
egghead
~ 40 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today