diff --git a/smart-hut/src/App.js b/smart-hut/src/App.js index 56c3095..fd6ccee 100644 --- a/smart-hut/src/App.js +++ b/smart-hut/src/App.js @@ -73,9 +73,11 @@ class App extends React.Component { this.setState({ error: res.data.message }); + return this.state.error; } }).catch(err => { console.log(err); + return {status : "Errore"}; }); }; diff --git a/smart-hut/src/client_server.js b/smart-hut/src/client_server.js index 1d61886..879d53d 100644 --- a/smart-hut/src/client_server.js +++ b/smart-hut/src/client_server.js @@ -8,7 +8,7 @@ export var call = { .then(res => { return res; }).catch(err => { - console.error(err); + return err; }); }, register: function(data, headers) { diff --git a/smart-hut/src/views/Login.js b/smart-hut/src/views/Login.js index 4650666..3e406a0 100644 --- a/smart-hut/src/views/Login.js +++ b/smart-hut/src/views/Login.js @@ -8,6 +8,8 @@ export default class Login extends Component { user: "", password : "", fireRedirect: false, + error : {state : false, + message: ""}, }; } @@ -23,10 +25,9 @@ export default class Login extends Component { user: this.state.user, params : params, }).then(res => { - if (res === '400') { - console.log('error'); - } else { - console.log("SUCCESS"); + if (res.status === "Errore") { + this.setState({error: {state: true, + message: "Errore"}}); } }).catch(err => { console.log(err); @@ -51,13 +52,19 @@ export default class Login extends Component { href="/" > - Go Home + Go Home +
Log-in to SmartHut
-
+ +