Hi, I’m not quite understanding my use case with async and await. I’m using react native that is connected to a meteor backend with methods.
Everytime I click charge payment (through stripe) it waits until the process is done but then only returns undefined. Any help will be very appreciated
React native client:
if (formFieldsValid) {
return new Promise((success, failure) => {
Meteor.call('checkoutCall', value, stripeToken, (error, result) => {
if (error) {
console.warn('Error: ' + error);
failure(error);
}
else {
console.warn('Success: ' + result);
success(result);
}
});
});
}
Meteor server backend
Meteor.methods({
async checkoutCall(value, stripeTokenInfo) {
const stripeToken = stripeTokenInfo;
const userValue = value;
const charge = await stripe.charges.create({
amount: 1000,
currency: 'usd',
source: stripeToken
}, function(err, charge) {
console.log(err, charge);
if (charge) {
return charge;
} else {
return err;
}
});
},
});