0

My cloud log says that it cannot call the method "success" of undefined at query.first.success however i dont understand this because my console.log is showing up which is called inside of the success block. What is undefined in this code?

var query = new Parse.Query("Messages");
  query.first({
    success: function(results, response){

      console.log("The first object was retrieved");
      body = (results.get("messageBody"));
      senderName = (results.get("senderName"));
      senderId = (results.get("senderId"));

      results.destroy({
        success: function(results){

        }, error: function(results, error){

        }
      });
      response.success(results);
    }, error: function(error){
      response.error("Error");
    }

  });
ian
  • 1,002
  • 2
  • 12
  • 29
  • 1
    Well, where is `response` defined? – Bergi Oct 07 '14 at 19:32
  • okay. i edited my question showing where i added response but its still showing up as the same error – ian Oct 07 '14 at 19:38
  • I don't think a [Query](https://parse.com/docs/js_guide#queries) does give you access to a `response` object. You're setting up a [cloud function](https://parse.com/docs/cloud_code_guide#functions), aren't you? – Bergi Oct 07 '14 at 19:43
  • yes this snippet is inside of an afterSave function – ian Oct 07 '14 at 19:44
  • Hm, it seems that afterX functions do not have access to the `response` object… – Bergi Oct 07 '14 at 19:49

0 Answers0