1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00

Fix error handling on AJAX request

This commit is contained in:
vrde 2015-05-27 17:55:09 +02:00
parent 3c3504d773
commit 97abafda0d

View File

@ -54,11 +54,16 @@ let ShareForm = React.createClass({
},
body: JSON.stringify(this.getFormData())
})
.then((response) => {
if (response.status >= 200 && response.status < 300)
return response
throw new Error(response.statusText)
})
.then((response) => response.json())
.catch(function(error) {
.catch((error) => {
this.setState({errors: error});
console.log('request failed', error);
}.bind(this));
});
//.then(FetchApiUtils.status)
@ -102,4 +107,4 @@ let ShareForm = React.createClass({
}
});
export default ShareModalButton;
export default ShareModalButton;