-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Responding to a cloud function with a parse object #985
Comments
It seems that I need to JSON.stringify my object response. Why do we have this change? |
@cyboolo yes you have to stringily the JSON object as the result is passed directly to the network response. You can call |
It seems that as of #1066 I properly receive a Parse.Object in the client |
Seems to be fixed and no response in many days, closing. |
Hi guys, We are in the process of migrating from Parse.com to our own hosted server using We experienced that using However, as soon as we added attributes to the object with thisIsAnParseObject.set("foo", "bar")
response.success(thisIsAnParseObject) Only the following information from the cloud code was returned to the client: {"result":[
{"__type":"Pointer","className":"Moment","objectId":"Gw3jXrg1UM"}
]} When using Is it documented anywhere that
|
This seems to work correctly if you call .toJSON on the top level object, but any of it's properties that contain objects are not affected, they still just pass down the reference. How would you correctly go about handling the scenario where you have an object that has a relation to a user reference. |
When I was using Parse promises from an outside node.js file to my main.js Cloud file. I was running into a similar problem where Parse Objects were returning without a __type field like:
So, when I would received the result in my iOS application via a Cloud Code call, it wasn't understanding that my Parse Object was supposed to be an Order. It just saw it as JSON. So, I had to use:
I used this encoding function before I resolved my order object to the cloud code main.js file, and my Order Object printed out as:
You can see the __type field was retained, so now my iOS application receives a properly typed object. This took me a while to figure out, and toJSON/JSON.stringify were not working for me, but ultimately encoding did the correct thing. I hope this might help someone else. |
Using version 2.6.5 here. Example:
Javascript sdk code:
|
But where as in the failure response , if i tried to do the same it thrown an error and by default it is responding a valid JSON response |
This is a pretty old thread regarding old versions of Parse. If you use the latest version, the code below should work:
|
Exact same issue as @DFranch. As soon as you use .set() on the object, the server will return undefined values for attributes (or no attributes at all).
If you save the object (object.save()) before returning it to client however, attributes will have values including newAttribute.
Returning JSON.stringify(object) to client without saving object first also returns object in JSON format containing all attributes and their values.
server version: 3.9.0 (but issue happens with earlier versions as well) |
Hello
I have a simple function to get User object:
Before I was with parse server version 2.0.0 and now I have updated to last version.
On 2.0.0 I could get all the fields for my User (more than 20).
And now, I just get this response on the client:
t {_objCount: 0, className: "_User", id: "LPoRpS4Z6P"}
I did not change my cloud code. Login is working but I have bugs after login when I want to get User object.
Could you tell me how to deal with this issue?
Environment Setup
Mac / Chrome
The text was updated successfully, but these errors were encountered: