EdgeHTML 17 中带有 Fetch 的 URLSearchParams

问题描述 投票:0回答:1

我仅在 EdgeHTML 17 中使用 URLSearchParams 发布表单数据时遇到问题。有谁知道最新更新有什么问题吗?

我正在使用以下 NPM 包作为旧版浏览器的 polyfill:

  1. whatwg-fetch:“2.0.4”
  2. promise-polyfill:“8.0.0”
  3. url-search-params-polyfill:“4.0.0”

这是我正在使用的代码:

fetch("/api/checkout", { method: 'POST', headers: new Headers({
        "X-Requested-With": "FetchAPI",
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
}), credentials: 'include', body: new URLSearchParams($("#MyForm").serialize()) })
.then((msg) => {
    return msg.json();
}).then((data) => {
    console.log(data);
});
fetch-api microsoft-edge
1个回答
2
投票

看来edge不再自动在body上执行toString操作了。通过将

.toString()
添加到主体中,它应该可以工作。

© www.soinside.com 2019 - 2024. All rights reserved.