saving MVP for review

This commit is contained in:
2021-12-21 13:48:33 -06:00
parent e2cfc6984e
commit 2f30b5c802
+24 -8
View File
@@ -12,7 +12,7 @@ export const ProfileForm = () => {
const editprofileinfocall = () => {
fetch(`https://localhost:8088/users/${founduser.id}`, {
fetch(`http://localhost:8088/users/${founduser.id}`, {
method: 'PUT',
body: JSON.stringify({
name: editedusername,
@@ -24,14 +24,30 @@ export const ProfileForm = () => {
}
}).then(response => {
return response.json()
}).then(json => {
console.log(json)
this.setState({
user:json
});
// }).then(json => {
// console.log(json)
// this.setState({
// user:json
// });
}).then(() => history.push("profile/Profile"))
}
// PUT request using fetch inside useEffect React hook
// const editprofileinfocall = () => {
// const requestOptions = {
// method: 'PUT',
// // headers: { 'Content-Type': 'application/json' },
// // body: JSON.stringify({ name: 'React Hooks PUT Request Example', email:'This string' })
// };
// fetch(`http://localhost:8088/`, requestOptions)
// .then(response => response.json())
// .then(data => this.setState({ postId: data.id }));
// empty dependency array means this effect will only run once (like componentDidMount in classes)
// };
useEffect(
() => {
const desireduser = userpool.find((userobj) => userobj.id === parseInt(usertoedit))
@@ -48,9 +64,9 @@ export const ProfileForm = () => {
<h2>Edit Profile Data</h2>
<form id="edituserform">
<label for="fandlname">First and Last Name</label><br/>
<input type="text" id="fndlname" name="fandlname" onChange={(e) => {seteditedusername(e.target.editedusername)}}/><br/>
<input type="text" id="fndlname" name="fandlname" onChange={(e) => {seteditedusername(e.target.value)}}/><br/>
<label for="email">Email</label><br/>
<input type="text" id="email" name="email" onChange={(e) => { setediteduseremail(e.target.editeduseremail)}}/>
<input type="text" id="email" name="email" onChange={(e) => { setediteduseremail(e.target.value)}}/>
<button type="button" id="submitbutton" name="submitbutton" form="edituserform" onClick={()=> editprofileinfocall()}>Submit</button>
</form>