3

Problem:

I'm trying to return a full object, instead I keep getting a pointer back. I think it might be because I modify the object, then save, then return it in the response. How would I be able to modify, save, and return the full object and not the pointer?

Code: Only relevant code is shown:

getPicture(username, {
  success: function (pictureObject) {
    response.success(pictureObject); //Always getting pointer
  },
  error: function (error) {
    response.error(error);
  }
});

...

function getPicture(username, callback) {
    var Pictures = Parse.Object.extend("Pictures");
    var pictures = new Parse.Query(Pictures);
    pictures.equalTo("username", username);
    pictures.find({
        success: function (results) {
                var object = results[0];
                object.increment("views", 1); 
                object.save(); //I think the issue is here
                callback.success(object);
        },
        error: function (error) {
            callback.error(error);
        }
    });
}

Thank you!

2
  • 1
    I think that you have to write object.save().then(function(newObj){ callback.success(newObj);}); Commented Jan 16, 2016 at 2:12
  • Thank you so much :). You should reply as an answer so I can accept it! Commented Jan 16, 2016 at 2:19

1 Answer 1

1

You have to take the object after parse save it in the database.

try using

 object.save().then(function(newObject){
      callback.success(newObject);
 });

this will send the object after the save.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.