Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- class LoginForm extends Component {
- doLogin(){
- fetch('http://localhost:8080/login2',{
- method:'POST',
- credentials: 'same-origin',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- body:JSON.stringify({username:"admin", password:"admin"})
- })
- .then(response => response.json())
- .then(posts =>{
- this.setState({posts})
- });
- }
- render(){
- return (
- <div>
- <div id="collapse1" className="user-collapse collapse">
- <form >
- <input id="account-username" type="text" name="username" placeholder="user"/>
- <input id="account-password" type="password" name="password" placeholder="password"/>
- <button onClick={this.doLogin} className="account login__button btn btn-outline-success">Login</button>
- </form>
- </div>
- </div>
- );
- }
- }
- export default LoginForm;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement