I have a form that I submit via fetch
, I always get an error:
<code>400 (Bad Request)
</code>
<code>400 (Bad Request)
</code>
400 (Bad Request)
I can’t figure out what the error is for some time now.
I’m sure the acton
is correct!
Please tell me where I’m going wrong here.
<code>const SendMail = (event) => {
event.preventDefault();
fetch(event.target.action, {method:'post', body: new FormData(event.target)}).then(response =>
response.text()).then((response) => {
})
}
<form
action="...some action..."
method="post"
onSubmit={event => SendMail(event)}
>
<input type="text" />
<button type="submit">Submit</button>
</form>
</code>
<code>const SendMail = (event) => {
event.preventDefault();
fetch(event.target.action, {method:'post', body: new FormData(event.target)}).then(response =>
response.text()).then((response) => {
})
}
<form
action="...some action..."
method="post"
onSubmit={event => SendMail(event)}
>
<input type="text" />
<button type="submit">Submit</button>
</form>
</code>
const SendMail = (event) => {
event.preventDefault();
fetch(event.target.action, {method:'post', body: new FormData(event.target)}).then(response =>
response.text()).then((response) => {
})
}
<form
action="...some action..."
method="post"
onSubmit={event => SendMail(event)}
>
<input type="text" />
<button type="submit">Submit</button>
</form>