I'm working with Parse.com's Cloud Code to implement Mailgun and Stripe Cloud Methods.
When a Stripe payment is successfully charged, I use Mailgun to send an email to the user.
I've stored a company email "signature logo" on Parse, and I'd like to (optionally) get it to append to the HTML of the email I'm crafting. (Basically, getting the PFFile
's url()
and setting that as the src
of an img
).
I've got the "email crafting" code working fine, and I'm now just trying to get the logo's url and append it at the end of the email.
I thought I'd use promises to make my code cleaner, but it turns out I have a problem:
I want the same code to run whether my query returns a value or not. If so, I'll append the img
tag; if not, I'll skip adding the image.
In the interest of DRY (D on't R epeat Y ourself), I'd prefer to not enter essentially the same code twice, once on the success pathway and once on the failure pathway.
Based on the (somewhat) convoluted way Parse requires you to call other methods, I'd prefer to not wrap it up in another method (though I'm guessing that's the "right" thing to do here).
Is there any way to run a Parse.com JavaScript SDK Query synchronously?
Any other ideas for this scenario?