Here's what I'm trying to do:
handleFormSubmit(event){
let currentComponent = this;
const { t } = this.props;
event.preventDefault();
UserService.isAccount(event, this.props).then(function(status) {
if(status === statusCode.OK) {
UserService.forgottenPasswordEmail(event, currentComponent.props).then(function (status){
toast.notify("t('forgottenPassword.emailSent')");
})
} else {
toast.notify(t('forgottenPassword.emailNotSent'));
}
})
}
As seen above, I'm trying to pass this.props to the UserService.isAccount function to the UserService.forgottenPasswordEmail function which is called inside the .then of the last one. I've tried to reference this with currentComponent but it doesn't seem to work as I get 'Cannot read property 'constructor' of null'.
How can I achieve this?
Update. This shows Unhandled Rejection (TypeError): Cannot read property 'target' of undefined.
handleFormSubmit(event){
let currentComponent = this;
const { t } = this.props;
event.preventDefault();
const { aux } = event;
UserService.isAccount(aux, this.props).then(function(status) {
if(status === statusCode.OK) {
UserService.forgottenPasswordEmail(aux, currentComponent.props).then(function (status){
toast.notify("t('forgottenPassword.emailSent')");
})
} else {
toast.notify(t('forgottenPassword.emailNotSent'));
}
})
}