Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static contextTypes = {
- router: PropTypes.object
- }
- constructor(props,context){
- super(props,context);
- this.state = {
- fname:'',
- lname:'',
- emailaddress:'',
- password:'',
- mobile:'',
- user:'',
- login_pass:''
- }
- this.regi_data = this.regi_data.bind(this);
- this.login_data = this.login_data.bind(this);
- this.otpModalRef = React.createRef();
- }
- regi_data(e){
- this.setState({[e.target.name] : e.target.value}
- );
- }
- login_data(e){
- this.setState({[e.target.name] : e.target.value})
- }
- otpModalRef = ({onOpenModal}) => {
- this.showModal = onOpenModal;
- }
- componentDidMount(){
- }
- login = (e) => {
- e.preventDefault();
- axios.post('/api/signin', {
- user:this.state.user,
- password:this.state.login_pass,
- })
- .then(res => {
- console.log(res);
- this.context.router.history.push({
- pathname:'/',
- });
- })
- .catch(function (error) {
- console.log(error.message);
- })
- }
- register = (e,ref) => {
- e.preventDefault();
- axios.post('/api/user/add', {
- firstname: this.state.fname,
- lastname:this.state.lname,
- email:this.state.emailaddress,
- password:this.state.password,
- mobile:this.state.mobile
- },
- )
- .then(res => {
- console.log(res);
- this.showModal();
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement