Skip to content

Commit

Permalink
Signin.js
Browse files Browse the repository at this point in the history
  • Loading branch information
lambrugeorge authored Feb 18, 2024
1 parent 67330dc commit 1823ae9
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/components/Signin/Signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,23 @@ class Signin extends React.Component {
};

onSubmitSignIn = () => {
const { signInEmail, signInPassword } = this.state;

fetch('https://mybackend-dfd1.onrender.com/signin', {
method: 'post',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: this.state.signInEmail,
password: this.state.signInPassword
email: signInEmail,
password: signInPassword
})
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then(response => response.json())
.then(user => {
if (user.id) {
this.props.loadUser(user);
this.props.onRouteChange('home');
} else {
console.error('Unexpected response from server:', user);
console.log('User not found:', user);
// Afișează un mesaj pentru utilizator despre eșecul autentificării
}
})
Expand Down

0 comments on commit 1823ae9

Please sign in to comment.