Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { t, history, navigation } = this.props;
let preparedCreditCard;
try {
// create credit card token
preparedCreditCard = await createCreditCardToken(creditCardInput, stripe);
await updateCard({ variables: { input: preparedCreditCard } });
this.setState({ submitting: false });
history ? history.push('/profile') : navigation.navigate('Profile');
} catch (e) {
this.setState({
submitting: false
});
if (isApolloError(e)) {
if (e.graphQLErrors[0].extensions.code === 'resource_missing') {
throw new FormError(t('stripeError'), e);
} else {
throw new FormError(t('serverError'), e);
}
} else {
throw new FormError(t('creditCardError'));
}
}
};
const onSubmit = (updateCard: any) => async (creditCardInput: CreditCardInput, stripe?: any) => {
setSubmitting(true);
let preparedCreditCard;
try {
// create credit card token
preparedCreditCard = await createCreditCardToken(creditCardInput, stripe);
await updateCard({ variables: { input: preparedCreditCard } });
setSubmitting(false);
history ? history.push('/profile') : navigation.navigate('Profile');
} catch (e) {
setSubmitting(false);
if (isApolloError(e)) {
if (e.graphQLErrors[0].extensions.code === 'resource_missing') {
throw new FormError(t('stripeError'), e);
} else {
throw new FormError(t('serverError'), e);
}
} else {
throw new FormError(t('creditCardError'));
}
}
};
const onSubmit = (addSubscription: any) => async (creditCardInput: CreditCardInput, stripe?: any) => {
setSubmitting(true);
let preparedCreditCard;
try {
// create credit card token
preparedCreditCard = await createCreditCardToken(creditCardInput, stripe);
await addSubscription({ variables: { input: preparedCreditCard } });
setSubmitting(false);
history ? history.push('/subscriber-page') : navigation.goBack();
} catch (e) {
setSubmitting(false);
if (isApolloError(e)) {
if (e.graphQLErrors[0].extensions.code === 'resource_missing') {
throw new FormError(t('stripeError'), e);
} else {
throw new FormError(t('serverError'), e);
}
} else {
throw new FormError(t('creditCardError'));
}
}
};