parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

JSON text did not start with array or object and option to allow fragments not set.

Open shawn458 opened this issue 10 years ago • 4 comments

Problem

I am getting the following response when I try to call [PFCloud callFunctionInBackground:] in my iOS app.

Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.

My configuration in the AppDelegate looks like: [Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> configuration) { configuration.applicationId = @"MY0PjsEc4aLZaWWoiYPnb4cju4VoKN7zyR41FPnR"; configuration.server = @"https://myappname.herokuapp.com/parse"; }]];

The interesting thing is Parse.Cloud.beforeSave function works as expected. Only when I am requested data back this issue appears.

Environment Setup

  • Server
    • parse-server version: 2.2.17
    • npm version: 3.8.6
    • node version: 4.3
    • parse-dashbboard version: 1.0.15
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Heroku
  • Database
    • MongoDB version: 3.0.9
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): mLab

Any help is appreciated

shawn458 avatar Aug 14 '16 14:08 shawn458

Ignore

shawn458 avatar Aug 14 '16 18:08 shawn458

I played around with this more and I am able to run a simple hello world cloud function. I get the

Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.

when I run any function that returns something.

Here is the cloud code I am calling:

Parse.Cloud.define("test", function(request, response) {
    var query = new Parse.Query("TestClass");

    query.find({
        success: function(results) {
            response.success(results);
        }, error: function(theerror) {
            response.error("user lookup failed: %@", error);
            console.log(theerror);
        }
    }); 
});

shawn458 avatar Aug 16 '16 00:08 shawn458

Turns out I just wrote the Cloud Code wrong. Closing.

shawn458 avatar Aug 16 '16 23:08 shawn458

Parse.Cloud.define("test", function(request, response) { var query = new Parse.Query("Classname");

query.find({
    success: function(results) {
        response.success(results);
                    console.log(results);

    }, error: function(theerror) {
        response.error("user lookup failed: %@", error);
        console.log(theerror);
    }
}); 

});

here is my cloud code , when i am calling this cloud code from application following error shows

error:Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

wellkeptbeauty avatar Apr 29 '17 13:04 wellkeptbeauty