如何使用提取API发布表单数据?
我的代码: fetch("api/xxx", { body: new FormData(document.getElementById("form")), headers: { "Content-Type": "application/x-www-form-urlencoded", // "Content-Type": "multipart/form-data", }, method: "post", } 我尝试使用提取API发布表单,其发送的正文如下: -----------------------------114782935826962 Content-Disposition: form-data; name="email" test@example.com -----------------------------114782935826962 Content-Disposition: form-data; name="password" pw -----------------------------114782935826962-- (我不知道为什么每次发送时边界数字都会更改...) 我希望它使用“ Content-Type”:“ application / x-www-form-urlencoded”发送数据,我该怎么办?或者,如果我只需要处理它,如何在控制器中解码数据? 向谁回答我的问题,我知道我可以做到: fetch("api/xxx", { body: "email=test@example.com&password=pw", headers: { "Content-Type": "application/x-www-form-urlencoded", }, method: "post", } 我想要的是类似jQuery中的$(“#form”)。serialize()(不使用jQuery)或在控制器中解码mulitpart / …