1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +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()) 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()) .then((response) => response.json())
.catch(function(error) { .catch((error) => {
this.setState({errors: error}); this.setState({errors: error});
console.log('request failed', error); console.log('request failed', error);
}.bind(this)); });
//.then(FetchApiUtils.status) //.then(FetchApiUtils.status)