带有Amazon-Cognito-identity-js包的Nuxt应用程序提供了未定义错误提取 [英] Nuxt application with amazon-cognito-identity-js package gives error fetch is not defined
问题描述
我在nuxt应用程序中包括了amazon-cognito-identity-js软件包,我想使用此软件包提供的登录方法/注册方法。
I included amazon-cognito-identity-js package in nuxt application and I want to use the sign in method/sign up methods which are provided by this package.
但是我遇到以下错误
未定义获取
我安装了node-fetch并修改了node_module /亚马逊认知身份js / Clinet.js如下
I installed node-fetch and modified node_module/amazon-cognito-identity-js/Clinet.js as below
const fetch = require('node-fetch');
const fetch = require('node-fetch');
解决了我的问题,但我不想修改节点包。
that solves my prob but I dont want to modify node package.
推荐答案
请参见文档:
注:此库使用Fetch API。对于较旧的浏览器或
Node.js,您可能需要包括一个polyfill。例如。
Note: This library uses the Fetch API. For older browsers or in Node.js, you may need to include a polyfill. For example.
global.fetch = require('node-fetch');
var AmazonCognitoIdentity = require('amazon-cognito-identity-js');
这篇关于带有Amazon-Cognito-identity-js包的Nuxt应用程序提供了未定义错误提取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!