javascript - Callbacks from Mandrill function are not called from Parse Cloud Code -


i starting parse cloud code, , i'm not familiar javascript...

i've taken couple of parse cloud code examples , come function sends email based on values of fields in "event" objects:

parse.cloud.define("sendemailreminders", function(request, response) {     parse.cloud.usemasterkey();     var successmessage = "";     var query = new parse.query("event");     query.equalto("reminderstatus", "pending");     query.equalto("reminderhow", "email");     query.each(function(event) {         var remindersendto = event.get("remindersendto");         var toarray = [];         remindersendto.foreach(function(entry) {             var emailtext = entry.sendto;             var nametext = entry.name;             var typetext = entry.type;             var oneperson = {                  email: emailtext,                 name: nametext,                 type: typetext             };             toarray.push(oneperson);         });         var remindersendfrom = event.get("remindersendfrom");         var remindersendfromname = event.get("remindersendfromname");         var remindertitle = event.get("remindertitle");         var remindertext = event.get("remindertext");          console.log("sending email to: " + remindersendto + "; " + remindertitle + "; " + remindertext + "; ");          mandrill.sendemail(             {                 message: {                     text: remindertext,                     subject: remindertitle,                     from_email: remindersendfrom,                     from_name: remindersendfromname,                     to: toarray                 },                 async: true             },             {                 success: function(httpresponse) {                     console.log(httpresponse);                     event.set("reminderstatus", "sent");                 },                 error: function(httpresponse) {                     console.log(httpresponse);                     event.set("reminderstatus", "error");                 }             }         );     }).then(         function() {             // set job's success status             response.success(successmessage);         },          function(error) {             // set job's error status             response.error("uh oh, went wrong.");         }     ); }); 

i have required mandrill configuration code included @ start of file:

var mandrill = require('mandrill'); mandrill.initialize('my api key'); 

this works, , emails sent.

the problem have need mandrill.sendemail() callbacks update "event" object success/failure of send recorded.

but never see these callbacks being called...

i'm thinking it's sendemailreminders function completing , sending response.success() before response has come mandrill servers...??? don't know how fix this.

i hope can me fix this.

thanks mike


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -