Guest User

Untitled

a guest
Feb 21st, 2020
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. import React, { Component } from "react";
  2. import "./styles/Login.css";
  3. import {Link} from 'react-router-dom';
  4.  
  5.  
  6. // import { NavItem, Nav} from "react-bootstrap";
  7. // import Signup from './components/Signup.js';
  8. // import {createAppContainer,navigation} from 'react-navigation';
  9. // import {createStackNavigator} from 'react-navigation-stack';
  10.  
  11.  
  12. class Signin extends Component {
  13.  
  14. state = {
  15. on: false,
  16. newsItems: [],
  17. messageList: [],
  18. username:'',
  19. password:''
  20. }
  21.  
  22. checklogincred() {
  23. fetch('http://127.0.0.1:5000/login', {
  24. method: 'POST',
  25. headers: { //MODIFY HEADERS
  26. 'Content-Type': 'application/json',
  27. },
  28. body: JSON.stringify({
  29. 'username':this.state.username,
  30. 'password':this.state.password
  31. })
  32. })
  33. .then((response) => response.json())
  34. .then((responseJson) => {
  35. console.log(responseJson);
  36. // this.setState({
  37. // loading: false,
  38. // // data: responseJson.data,
  39. // })
  40. // alert(JSON.stringify(responseJson));
  41. // alert(JSON.stringify(data));
  42. // <a eventkey={1} componentClass={Link} href="/Home" to="/Home"></a>
  43. })
  44. .catch((error) => {
  45. console.error(error);
  46. });
  47.  
  48. }
  49.  
  50. //btnClick() {
  51.  
  52. // route to new page by changing window.location
  53. // window.location="./Signup.js" //to open new page
  54. // } onClick={this.btnClick.bind(this)}
  55.  
  56.  
  57.  
  58. render() {
  59. return (
  60.  
  61.  
  62.  
  63. <div className="form-wrapper">
  64. <h1>Signin Now</h1>
  65. <form className="form-login">
  66. <div className="Email">
  67. <label>Username</label>
  68. <input className="input-login"
  69. placeholder="Username"
  70. type="username"
  71. onChange={(username) => this.setState({username})}
  72. required />
  73. </div>
  74.  
  75. <div className="password">
  76. <label >Password</label>
  77. <input
  78. className="input-login"
  79. placeholder="Password"
  80. type="password"
  81. onChange={(password) => this.setState({password})}
  82. required
  83. />
  84. {/* <button className="forgot" type="button">Forgot Password ?</button> */}
  85. </div>
  86.  
  87. <div className="login">
  88. <button type="submit" onClick={this.checklogincred}>Signin</button>
  89. </div>
  90. </form>
  91.  
  92. {/* <a eventkey={1} componentClass={Link} href="/Signup" to="/Signup">
  93. <button type="button" className="login"> New User ? Register </button>
  94. </a> */}
  95.  
  96.  
  97. </div>
  98. );
  99. }
  100. }
  101.  
  102.  
  103.  
  104. export default Signin;
Add Comment
Please, Sign In to add comment