在EdgeHTML中获取的URLSearchParams 17

时间:2018-06-12 16:50:15

标签: fetch microsoft-edge fetch-api

我无法在EdgeHTML 17中使用URLSearchParams发布表单数据。有谁知道最新更新的任何问题?

我使用以下NPM软件包作为旧浏览器的polyfills:

  1. whatwg-fetch:“2.0.4”
  2. promise-polyfill:“8.0.0”
  3. url-search-params-polyfill:“4.0.0”
  4. 以下是我正在使用的代码:

    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);
    });
    

1 个答案:

答案 0 :(得分:1)

似乎edge不再自动在主体上执行toString了。通过将.toString()添加到正文中,它应该可以工作。