【发布时间】:2018-05-01 05:58:19
【问题描述】:
我目前正在为Internet Explorer 11 和Fetch API 苦苦挣扎。
我有以下 fetch-call unsing TypeScript:
await fetch(theForm.action, { method: theForm.method, body: formData, credentials: "include" })
.then((response: Response) => {
if (response.status === 500)
throw Error(response.statusText);
if (response.redirected && response.url)
return window.location.href = response.url;
return response.json();
})
.catch((error: Error) => {
return this.setState({ isSubmitting: false, internalServerError: error });
});
代码被 ts 编译为ES2015,然后使用 babel 编译为ES5。我还添加了babel-polyfill。示例代码在 IE 以外的其他浏览器上按预期工作。
事实证明,IE 中的Response-object 完全不同,甚至没有属性redirected 和url 始终为空。
我应该使用什么 polyfill 在 IE 中完成这项工作吗?如果没有,什么是好的解决方法?
【问题讨论】:
标签: typescript internet-explorer babeljs fetch-api polyfills