You can set body
to an instance of URLSearchParams
with query string passed as argument
fetch("/path/to/server", {
method:"POST"
, body:new URLSearchParams("[email protected]&password=pw")
})
document.forms[0].onsubmit = async(e) => {_x000D_
e.preventDefault();_x000D_
const params = new URLSearchParams([...new FormData(e.target).entries()]);_x000D_
// fetch("/path/to/server", {method:"POST", body:params})_x000D_
const response = await new Response(params).text();_x000D_
console.log(response);_x000D_
}
_x000D_
<form>_x000D_
<input name="email" value="[email protected]">_x000D_
<input name="password" value="pw">_x000D_
<input type="submit">_x000D_
</form>
_x000D_