Pompey Magnus
Pompey Magnus

Reputation: 2341

with a standard html form post, no body

I have this form:

<form action="/signup" method="post">

                <div class="field">
                    <label class="label">{{ message }}</label>
                </div>

                <div class="field">
                    <label class="label">Name</label>
                    <div class="control">
                        <input class="input" type="text" placeholder="Text input" value="joe">
                    </div>
                </div>



                <div class="field is-grouped">
                    <div class="control">
                        <button class="button is-link" type="submit">Submit</button>
                    </div>
                    <div class="control">
                        <button class="button is-link is-light">Cancel</button>
                    </div>
                </div>

            </form>

the oak server is saying i don't have a request body. chrome dev tools is saying i do not have any Form Data.

Can anyone see why this form would post without form data?.

Request URL: https://localhost:8000/signup
Request Method: POST
Status Code: 200 OK
Remote Address: [::1]:8000
Referrer Policy: strict-origin-when-cross-origin

Upvotes: 0

Views: 367

Answers (1)

Ethicist
Ethicist

Reputation: 827

Specify the name attribute for your <input> element so itself and the value associated with it can be sent as name-value pairs.

Try defining <input> element like this instead:

<input name= "text-input" class="input" type="text" placeholder="Text input" value="joe">

so the request would look like this when the input would be, for e.g "myText" (shortened for demonstration purposes):

Request URL: https://localhost:8000/signup 
Request Method: POST

text-input=myText

The MDN docs provide some insight on this too, you might want to visit for clarity.

Upvotes: 2

Related Questions