Created
January 2, 2020 15:07
-
-
Save AlexzanderFlores/74c9a33d9d5e6ae4eb3a9808acdb79dd to your computer and use it in GitHub Desktop.
AWS Cognito + React JS Tutorial: Account Registration (2020)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.youtube.com/watch?v=-qo5GFdN-Ck | |
import React, { useState } from 'react'; | |
import { CognitoUserPool } from 'amazon-cognito-identity-js'; | |
export default () => { | |
const [email, setEmail] = useState(''); | |
const [password, setPassword] = useState(''); | |
const poolData = { | |
UserPoolId: 'us-east-1_8WMsl8AMg', | |
ClientId: '41qemsprq6sqqjraln2kqr04k7' | |
}; | |
const UserPool = new CognitoUserPool(poolData); | |
const onSubmit = event => { | |
event.preventDefault(); | |
UserPool.signUp(email, password, [], null, (err, data) => { | |
if (err) console.error(err); | |
console.log(data); | |
}); | |
}; | |
return ( | |
<div> | |
<form onSubmit={onSubmit}> | |
<input | |
value={email} | |
onChange={event => setEmail(event.target.value)} | |
/> | |
<input | |
value={password} | |
onChange={event => setPassword(event.target.value)} | |
/> | |
<button type='submit'>Signup</button> | |
</form> | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment