【发布时间】:2021-03-01 10:10:42
【问题描述】:
我正在尝试将 AWS Amplify 与 Cognito 集成到现有的 React-Native 应用程序中。
这是我的 aws-exports.js 文件的内容。
const config = {
identityPoolId: 'xxxxxxxx',
region: 'xxxxx',
userPoolId: 'xxxxx',
userPoolWebClientId: 'xxxxxxx'
}
export default config;
我在我的 index.js 文件中使用以下内容配置放大:
import Amplify from '@aws-amplify/core';
import awsConfig from './src/aws-exports'
Amplify.configure(awsConfig);
这是我尝试使用 Auth 方法注册用户等的地方:
import { Auth } from 'aws-amplify'
class AuthenticationService {
confirmationResult: any
phoneNumber: any
signInWithPhoneNumber() {
return new Promise((resolve, reject) => {
const strippedPhone = phone.replace(/\D/g, '')
const formattedPhone = `+1${strippedPhone}`
Auth.signUp({
username: 'jello',
password: 'jello',
attributes: {
phone_number: formattedPhone
}
})
.then((confirmationResult:any) => {
this.confirmationResult = confirmationResult
resolve(null)
})
.catch((error: any) => {
reject(error)
})
})
}
我在这里没有任何错误,但是我不断收到以下信息:
Unhandled JS Exception: Can't find variable: self
我已经搜索了一段时间,我偶然发现了"whatwg-fetch: 2.0.4" 但这并没有解决我的问题。
【问题讨论】:
标签: reactjs amazon-web-services react-native amazon-cognito aws-amplify