Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse.Object.save return doesn't contains "__type" #199

Closed
laullon opened this issue Feb 4, 2016 · 4 comments
Closed

Parse.Object.save return doesn't contains "__type" #199

laullon opened this issue Feb 4, 2016 · 4 comments

Comments

@laullon
Copy link

laullon commented Feb 4, 2016

Hi,

I have this cloud function:

Parse.Cloud.define("newPhoto", function (request, response) {
    var Photo = Parse.Object.extend("Photo");
    var p = new Photo();
    p.set("caption", 'tururu');
    p.save().then(function (np) {
        response.success(np);
    });
});

The 'np' object doesn't have the "__type" property, so it can be translated to a PFObject on my IOS app.

This happened we I deploy my app on a local Parse-server instance.
Please take a look of this bug: parse-community/parse-server#112

@laullon laullon changed the title Parse.Object.save return doesn't contains "_type" Parse.Object.save return doesn't contains "__type" Feb 4, 2016
@andrewimm
Copy link
Contributor

This is not an issue with the JS SDK -- the return type for save() is a Parse Object, which the server code needs to explicitly convert to the over-the-wire representation with ._toFullJSON().

@laullon
Copy link
Author

laullon commented Feb 4, 2016

Ok,

I know how to solve this when I return this:
response.success(np);

But no if I return something like this:
response.success({ photo : np });
or any other object that contains a ParseObject.

Any suggestion @andrewimm ?

@andrewimm
Copy link
Contributor

I believe parse-cloud-express needs to be rewritten to use the encode function from the JS SDK.

However, you can encode any of your server responses today by calling Parse._encode(value), so your code example becomes response.success(Parse._encode({ photo: np }));

@laullon
Copy link
Author

laullon commented Feb 4, 2016

Thanks @andrewimm I did solve the problem...

I even made a pull request to parse-server
parse-community/parse-server#252

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants