Я пытаюсь подтвердить пользователя, нажав на ссылку электронной почты через sendgrid. Ниже вы можете увидеть код, который я пытаюсь передать values.emailAddressVerificationToken, чтобы он передавался в мой файл действий, однако я получаю emailAddressVerificationToken неопределенным внутри моего компонента проверки.
проверить компонент
import { verifyEmailSubmit } from "../../stores/Auth/actions";
// gets the token in the URL
getVerifiedEmailToken = () => {
const query = parse(this.props.location.search);
return query.token;
};
componentDidMount(values) {
// this means the user has clicked the link, so we'll verify the email here
const { verifyEmail } = this.props;
console.log(verifyEmail);
console.log(values);
values.emailAddressVerificationToken = this.getVerifiedEmailToken();
verifyEmail(values);
}
const mapDispatchToProps = dispatch => ({
verifyEmail: params => dispatch(verifyEmailSubmit(params))
});
export default withRouter(
connect(
mapStateToProps,
mapDispatchToProps
)(VerifyEmailComplete)
);
файл действий авторизации
export function verifyEmailSubmit(params) {
const mutation = `
mutation {
verifyEmail(
emailAddressVerificationToken: "${params.emailAddressVerificationToken}"
)
}
`;
return dispatch => {
dispatch(authInProgress());
return ApolloService.mutate({ mutation })
.then(response => {
const { verifyEmail } = response.data;
dispatch(resetAppMessages());
dispatch(verifyEmailSuccess());
return verifyEmail;
})
.catch(error => {
dispatch(verifyEmailFailure());
// Need to throw this error so that the callee (react component) can use this error in it's own catch block
throw error;
});
};
}