Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- onSubmitSignIn = () => {
- console.log(this.state.signInPassword);
- fetch('http://localhost:3000/signin', {
- method: 'post',
- headers: {'Content-Type': 'application/json'},
- body: JSON.stringify({
- name: this.state.signinName,
- password: this.state.signinPassword
- })
- })
- .then(response => response.json())
- .then(user => {
- if(user.id){
- this.props.loadUser(user);
- this.props.onRouteChange('home');
- }
- })
- }
- app.post('/signin', (req, res) => {
- const { name, password } = req.body;
- console.log("FRONT END : ", password);
- console.log("BACK END: ", database[0].password);
- console.log("FRONT END : ", name);
- if(name == database[0].name && password == database[0].password){
- res.json(database[0]);
- }else{
- res.status(400).json("Couldn't get user");
- console.log('didnt work');
- }
- })
Add Comment
Please, Sign In to add comment