Receiving Form Data in Edge Function

Site name: catholica-en
Did I try “Ask Netlify”? Yes

I have a HTML form set up like this:

<form action="/edge/sign-up" method="POST">
  <label>
    Email Address:
    <input name="email" required type="email">
  </label>
  <label>
    Password:
    <input name="password" required type="password">
  </label>
  <label>
    Confirm Password:
    <input name="confirm-password" required type="password">
  </label>
  <button type="submit">Sign Up</button>
</form>

My Edge function is set up like this:

export default (request, context) => {
  const everything = JSON.stringify({ request: request, context: context });
  return new Response(everything, null, 2));
};

export const config = {
  path: "/edge/sign-up",
};

When I submit the form I see a blank page showing all the properties of the variable everything - but there are no properties or values related to what I typed in the form; there are no attributes named “email”, “password”, “confirm_password”, etc.

How can I post a form and receive the data in an Edge function?

Thanks for your time!
Chris

Request is a Web Standard, so you can refer to MDN docs: Request - Web APIs | MDN (mozilla.org) and find out more about Request.body or use one of the methods: Request - Web APIs | MDN (mozilla.org)

Thank you, that worked.