Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iron-form body data malformed #1702

Closed
amimof opened this issue Jun 1, 2015 · 1 comment
Closed

iron-form body data malformed #1702

amimof opened this issue Jun 1, 2015 · 1 comment

Comments

@amimof
Copy link

amimof commented Jun 1, 2015

POST requests using iron-form and sending JSON as request body, is misinterpreted by requesting URL. My test shows a simple nodejs server that accepts POST requests and prints out body using body-parser API. I'm using Polymer 1.0 with iron-form inside a custom component.

<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/iron-form/iron-form.html">
<link rel="import" href="../bower_components/paper-input/paper-input.html">
<link rel="import" href="../bower_components/paper-button/paper-button.html">

<dom-module id="app-bear-form">
    <style>
        #submit {
            background-color: #4CAF50;
            color: white;
            float: right;
        }
    </style>
    <template>

        <p>Create a bear</p>
        <form is="iron-form" id="form" method='POST' action="http://192.168.63.133:8080/api/bears">
            <paper-input label="Bear Name" name="name" required="true"></paper-input>
            <paper-input label="Bear Age" name="age"></paper-input>
        </form>
        <br/>
        <paper-button onclick="submitForm()" label="Create Bear" id="submit" raisedButton>Create</paper-button><br/>

    </template>
    <script>
    onclick="submitForm()"

        function submitForm() { 
            document.getElementById('form').submit();
        }

        Polymer({
            is: 'app-bear-form',
            ready: function() {

            },
            createBear: function() {
                this.$.form.submit();

            },
        });
    </script>
</dom-module>

The request body json data:
image

@tjsavage
Copy link
Contributor

tjsavage commented Jun 2, 2015

auto-moving this issue to PolymerElements/iron-form#7 and closing this one

@tjsavage tjsavage closed this as completed Jun 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants