Application callback block failed Couchbase lite

I am facing the following issue while fetching data using a view anyone have any idea about this

“Application callback block” is the map (or reduce) function of your view.
“Failed” means it threw an exception.
There’s a bug in your callback that you need to diagnose.

Thanks for the response @jens

Can you please give me an idea how I can diagnose it I had tried to validate the views which are available in database_design_docs like

      map: function(doc) {
        if (doc && doc.type === "client") {
          emit(doc._id, doc);
    }, ```

Can you please let me know about which callback should I need to check with?

The function you showed is fine. (Although there’s no need to check whether doc exists; it always does.) What does your actual function look like?

Couchbase Lite should have logged info about the exception to the app’s console; did you look there?

Its giving me some warning in the Xcode console as

22:21:21.318‖ WARNING: View litehq_design_doc/diets could not compile javascript map fn: function (doc) {
          if (doc.type === "diet") {
            emit(doc.user, doc);
        } {at -[CBLView(REST) compileFromProperties:language:]:44}

and giving me “{“status”:500,“error”:“Application callback block failed”}” this error in chrome console actually I am working on a React Native app

It’s saying there’s a syntax error in the function, but I can’t see one, so that’s weird.

The function will fail at runtime if there’s a document whose type is "diet" but which doesn’t have a user property, since emit requires a non-null key, but that doesn’t seem to be what’s going on here.

Yes thats the main issue I am facing as not able to trace down the things where I am making a mistake. I had even tried like

if (doc.user&& doc.type === “diet”) {
emit(doc.user, doc);

still no luck

What environment are you using? The most likely guess is that the JavaScript view compiler isn’t registered, but if you’re using PhoneGap/Cordova that’s done for you.

I am working with React Native actully

We don’t officially support React Native; the Couchbase Lite plugin for that is being developed externally. You should ask for help on their forum or Github Issues or wherever they hang out :slight_smile:

Ok no issues let me check anyways thanks for your time