diff --git a/src/components/Board.js b/src/components/Board.js index 1d06ee1309e818e091bc215aa6f7fb3a5a8c07ee..c698e4d9139fcfd69f2198b13da1ab4ca6f33522 100644 --- a/src/components/Board.js +++ b/src/components/Board.js @@ -17,7 +17,11 @@ const getMessagesList = async (board) => { // Gets the list of users const getUserList = async () => { - + axios.get(API_URL+'/users' , { + responseType : 'json' + }).then( response => { + this.setState({ tableData: response.data }) + }) }; // Gets the data from a board @@ -30,6 +34,7 @@ const Board = (props) => { return ( <div> + <h3>A board will be there soon</h3> </div> ); }; diff --git a/src/components/Login.js b/src/components/Login.js index d6d49418e6a2e80593b55a9c2c1d03e19f2ca2a4..dc54c02a0a1022c278adb9ca6e1c832218c0948b 100644 --- a/src/components/Login.js +++ b/src/components/Login.js @@ -7,12 +7,30 @@ const API_URL = 'http://138.195.142.10'; // Attempts to login and if successful stores the userId in localStorage and redirects to the boards list const handleLogin = async (username, password) => { - + const requestOptions = { + method : 'POST', + body : JSON.stringify({ + "username" : username, + "password" : password, + }), + } + fetch(API_URL+'/login', requestOptions) + .then(response => response.json()) + .then(data => this.setState({ postID:data.id })) }; // Attempts to register and if successful stores the userId in localStorage and redirects to the boards list const handleRegister = async (username, password) => { - + const requestOptions = { + method : 'POST', + body : JSON.stringify({ + "username" : username, + "password" : password, + }), + } + fetch(API_URL+'/users', requestOptions) + .then(response => response.json()) + .then(data => this.setState({ postID:data.id })) }; const Login = () => { @@ -20,6 +38,7 @@ const Login = () => { return ( <div> + <h3>Hello There</h3> </div> ); };