Repository navigation
Cloud function retuning array of PFObject, can not be cast in iOS (Swift) #112
Description
Activity
cc @nlutsenko
Sounds strange - any chance you can try to print out that array? It might be coming back as array of dictionaries instead of array of Parse Objects / Pointers - that's the only reason that comes to my mind.
Self hosted parse-server
{
"result": [
{
"copy": "undefined",
"createdAt": "2016-02-01T10:00:20.702Z",
"duration": 15,
"endTime": {
"__type": "Date",
"iso": "2016-02-01T14:15:00.000Z"
}
]
}Parse.com
{
"result": [
{
"__type": "Object",
"className": "Program",
"copy": "undefined",
"createdAt": "2016-02-01T11:00:39.837Z",
"duration": 15,
"endTime": {
"__type": "Date",
"iso": "2016-02-01T14:45:00.000Z"
}
]
}I haven't print them out, At least in XCode debugger, it was showing NSDirectory. I will confirm it if there is difference between them.
I have the same problem, I think is because the result is missing "__type" and "className"
I thin this can be related to parse JS lib, ParseObject.js have 2 methods:
- _toFullJSON , this one add the "__type" and "className"
- toJSON , this one don't....
and the express framework is using "toJSON"
Yup - it needs the
__typenotation to be able to recognize that it's a full object.I'm trying to use a "json replacer" function to use _toFullJSON function, or to add the both properties, bu, no luck so far...
Any recommendation?
I am not hands on with nodejs (that was the reason, I started with Parse), Anyone has any idea or work around to continue my migration? At this point I have stuck. Thanks a lot.
I opened a bug on the Parse-SDK-JS, I think the problem is there.
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 idea?
I did solve it...
PR: #252German: Thanks a lot. I just tested out and it works like a charm. Do you know when is it going to be in master branch?
Just merged it, already on master ;)
- addedtype:questionSupport or code-level questionSupport or code-level questionand removed
on Jul 11, 2021
I am returning PFObjects from cloud function(s) and in my app (iOS SDK), I am using Subclassing. However, it gives error:
fatal error: NSArray element failed to match the Swift Array Element typeIt works fine with api.parse.com but not with my local parse-server. Thanks