Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. import React, { Component } from 'react';
  2.  
  3. class LoginForm extends Component {
  4.  
  5.  
  6. doLogin(){
  7. fetch('http://localhost:8080/login2',{
  8. method:'POST',
  9. credentials: 'same-origin',
  10. headers: {
  11. 'Accept': 'application/json',
  12. 'Content-Type': 'application/json'
  13. },
  14. body:JSON.stringify({username:"admin", password:"admin"})
  15. })
  16. .then(response => response.json())
  17. .then(posts =>{
  18. this.setState({posts})
  19.  
  20. });
  21. }
  22.  
  23. render(){
  24. return (
  25. <div>
  26. <div id="collapse1" className="user-collapse collapse">
  27. <form >
  28. <input id="account-username" type="text" name="username" placeholder="user"/>
  29. <input id="account-password" type="password" name="password" placeholder="password"/>
  30. <button onClick={this.doLogin} className="account login__button btn btn-outline-success">Login</button>
  31. </form>
  32. </div>
  33. </div>
  34. );
  35. }
  36.  
  37. }
  38.  
  39. export default LoginForm;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement