es6 문법 예제1
class Signunpa extends React.Component {
constructor(){
super();
this.state = {
email: "",
password: "",
id:"",
comment:""
}
}
handleID = (event) => {
// console.log(event.target.value)
this.setState({
email: event.target.value
});
}
handlePW=(event) =>{
console.log("pwvalue : ", event.target.value)
this.setState({
password: event.target.value
});
}
handleLogin = () => {
const {email,id,comment}=this.state;
// console.log("button clicked")
console.log("this.state : ", this.state)
fetch("http://10.58.0.129:8000/reviewdetail/sign-up", {
method: "POST",
// headers: {
// "token": localStorage.setItem("wtw-token")
// },
body: JSON.stringify({
email: email,
password: password,
comment:comment
})
})
.then(response => response.json())
.then(response => {
if(response.message==="SUCCESS"){
this.props.history.push("/Signin");
}
es6 변수선언함으로서 간소화됨.