question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to pass data through amp-form?

See original GitHub issue

I have user information form. The form is validated using custom validation amp-form. My xhr-action attributes was pointing to my API url. When I submit my form with POST, my api returns nothing because req.body shows empty. Previously I’m using normal form action is working fine.

'/api/submit': { post: function(req, res){ console.log(req.body); } }

form(method="POST", action-xhr!='/api/submit/' + post_form_id + '?_csrf=' + csrf , target="_top", data-form-id=post_form_id, custom-validation-reporting="show-all-on-submit")

  input.form-control.name(
     type="text",
     title="Name is required (Maximum 20 characters only)",
     name="inputNameField",
     placeholder="Full name*",
     id="namefield"
     required,
     pattern="^[a-zA-Z \-\.\@\']{1,20}$")

  input(type="submit", value="Submit", class="btn btn-block btn-black")

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
xileftenurbcommented, May 18, 2017

I got the same problem until I found amp-form send all data of xhr request in enctype=“multipart/form-data”. If the server is not properly configured, there is a good chance body will remain empty in this condition.

I hope this help.

0reactions
aghassemicommented, Jun 30, 2017

Closing as it seems the bug is related to incorrect server-side implementation. Note that we are planning to support other enctypes for amp-form in https://github.com/ampproject/amphtml/issues/7607

Read more comments on GitHub >

github_iconTop Results From Across the Web

Example: <amp-form> - amp.dev
The amp-form extension allows the usage of forms and input fields in an AMP ... It's possible to show custom success or error...
Read more >
How to Manage Data Collected via AMP Forms - Yespo
Go to your account in our service and open the corresponding email with the AMP form. Click ϟHTML to open the settings. Insert...
Read more >
Implementing AMP Forms from Start to Finish with amp-form ...
Learn how to implement forms in AMP using practical examples such as submitting a search on a blog and collecting newsletter subscribers.
Read more >
Post an amp-form with a templated url - Stack Overflow
You can't change the URL directly, but amp-form will append your input field values to the URL as query parameters. This form:
Read more >
How to develop & implement AMP forms on AMP pages
<script async custom-element="amp-form" ... this makes the browser to send the data using Fetch API when available, and fallback to XMLHttpRequest API for ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found