使用 cognito 进行身份验证时,在 IE11 上未定义提取

Fetch is undefined on IE11 when authenticating with cognito

我有一个 ember 应用程序,我可以在其中登录并使用 ember-cognito 和 ember-simple-auth 对我进行身份验证。

this.get('sessionService').authenticate('authenticator:cognito', credentials).then(() => {
         console.log('authenticated');
    }).catch(( reason ) => {

        console.log(reason);
    });

这适用于所有浏览器,除了我收到错误 'fetch is not defined' 的浏览器。

这出现在 catch 部分,这意味着 cognito 正在尝试使用 fetch。

我一直在研究这个问题,但找不到适合我的情况的解决方案。

只需包含 isomorphic-fetch 作为 polyfill 即可使其在不受支持的浏览器上运行。

https://github.com/matthew-andrews/isomorphic-fetch

请安装 isomorphic-fetch polyfill :

npm install --save isomorphic-fetch es6-promise

有关详细信息,请访问 here