Skip to content

Issue with Cloud function which returns list of custom object #63

Closed
@ghost

Description

Hi, I have a problem with Cloud Function.

When for exemple, I made this sample from the example in the lib :

void getAllItems() async {
    var apiResponse = await TestObject().getAll();

    if (apiResponse.success && apiResponse.result != null) {
      for (var test in apiResponse.result) {
        print(ApplicationConstants.keyAppName + ": " + (test as TestObject).title);
      }
    } else {
      print(ApplicationConstants.keyAppName + ": " + apiResponse.error.message);
    }
  }

I have this payload (with debug print, and it prints correctly the title of my test object in DB)

Payload: [{"className":"TestObject","objectId":"A","createdAt":"B","updatedAt":"C","title":"Hello"}]

But when I tried to retrieve it with Cloud Function, like this :

getObjects() async {
    var function = ParseCloudFunction('getObjects');
    ParseResponse response = await function.execute();
    return response;
  }

The payload is different from the first payload

Payload: [{title: Hello, createdAt: B, updatedAt: C, objectId: A, __type: Object, className: TestObject}]

And when I try to print the title of my test object like before (before, it works well), it doesn't work and I have this error :

Dart Error: Unhandled exception:
E/flutter (23910): type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'TestObject' in type cast

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions