alexabbott / firebase-cms

A CMS + E-commerce platform built with Angular and Firebase
https://fir-cms-76f54.firebaseapp.com/
MIT License
313 stars 125 forks source link

Error in Funsctions & Storage #21

Closed viralpatel380 closed 1 year ago

viralpatel380 commented 6 years ago

Getting error 403 in Firebase Storage as well as getting error in firebase funcions ReferenceError: error is not defined at admin.database.ref.once.then.then.then.then (/user_code/index.js:78:32) at process._tickDomainCallback (internal/process/next_tick.js:135:7)

Here is the Actual Code // Add a payment source (card) for a user by writing a stripe payment source token to Realtime database exports.addPaymentSource = functions.database .ref('/stripe_customers/{userId}/sources/{pushId}/token').onWrite((change, context) => { const source = change.after.val(); if (source === null){ return null; } return admin.database().ref(/stripe_customers/${context.params.userId}/customer_id) .once('value').then((snapshot) => { return snapshot.val(); }).then((customer) => { return stripe.customers.createSource(customer, {source}); }).then((response) => { return change.after.ref.parent.set(response); }, (error) => { return change.after.ref.parent.child('error').set(userFacingMessage(error)); }).then(() => { return reportError(error, {user: context.params.userId}); }); });