In my dataloader the response I get I do this :
method: 'PUT'
})
.then(response => response.json().then(json => {
response.ok ? json : Promise.reject(json)}))
.then(schematizeResponse)
On my Screen I have a button that dispatches the function and which is :
_updateValues(){
try{
//update Email
this.props.editProfile({
currentUserToken: this.props.userSession.currentUserToken,
data: {
email: this.state.newEmail
}
})
this.state.updated= true;
}
catch(e) {
this.state.updated= false;
}
When the response fails, I get :
Possible unhandled promise rejection (id:0 ) and the response body.
The editProfile that I call through props is in my controller :
function mapDispatchToProps(dispatch) {
return {
dispatch,
editProfile: bindActionCreators(editProfileRequest, dispatch)
};
}
Update :
this.props.editProfile({
currentUserToken: this.props.userSession.currentUserToken,
data: {
email: this.state.newEmail
}
})
Here i need :
try {
this.props.editProfile({
currentUserToken: this.props.userSession.currentUserToken,
data: {
email: this.state.newEmail
}
})
}
catch( error ? )
{
this.setState({failedUpdate:true})
}
How do I handle the rejection ?