The Parse.com cloudcode refuses to enter the success or error state

Running this code in my Parse cloud, I noticed that when I call it from my app, it never enters the success or error statement. Could it be because the .save method isn't working?

Any assistance would be greatly appreciated :)

This is how I invoke the cloud function:

[PFCloud callFunctionInBackground:@"addFeeling"
                   withParameters:@{@"userId"           : [[PFUser currentUser]objectId],
                                    @"relationShipId"   : _friendship.objectId,
                                    @"tagId"            : [NSNumber numberWithInt:tag],
                                    @"reason"           : @"Hardcoded HomeView(409)",
                                    @"value"            : [NSNumber numberWithInt:value]}
                            block:^(NSString *result, NSError *error) {
                                if (!error) {
                                    DLog(@"results :%@", result);
                                }
                                else{
                                    DLog(@"Error : %@", error);
                                }
                            }];

And here's the cloud function itself:

Parse.Cloud.define("addFeeling", function(request, response) {
    var userId         = request.params.userId;
    var relationShipId = request.params.friendshipId;
    var tagId          = request.params.tagId;
    var reason         = request.params.reason;
    var value          = request.params.value;

    var Feels = Parse.Object.extend("Feels");
    var feeling = new Feels();
    feeling.set("id_friendship", relationShipId);
    feeling.set("value", value);
    feeling.set("tag", tagId);
    feeling.set("reason", reason);
    feeling.save({
        success: function () {
            var query = new Parse.Query("Feels");
            query.equalTo("id_friendship", relationShipId);
            query.find({
                success: function(results) {
                    if(results.length > 0)
                    {
                        result = results[0];
                        if(result.get("userFrom") == userId)
                            result.set("scoreTo"  , result.get("scoreTo") + value);
                        else
                            result.set("scoreFrom", result.get("scoreFrom") + value);
                        result.save();
                    }
                }
            });
            console.log("Save ok");
        },
        error: function (error) {
            response.error(error);
            console.log("Save ko");
        }
    });
});

This might seem really simple, but I'm just not familiar with JavaScript at all.

The error code I'm receiving is 141, and it never enters the success/error statements.

Answer №1

After completing the task you set out to do with your function, it is important to remember to use either response.success() or response.error() to signal completion.

You may already have this in place for handling errors, but don't forget to also include it for successful processing of query results.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Eliminate a specific element from the dataset

My question revolves around a data array used to populate three drop down <select> boxes. How can I eliminate duplicate values within the drop downs without affecting the array itself? For example: data = { firstbox_a: ['grpA_1','gr ...

Sending a unicode PHP variable to JavaScript is a breeze

I am attempting to transfer the titles and excerpts of Persian Wordpress posts to JavaScript. Below is the code in a .php script file: function change(){ document.getElementById("link").innerHTML = '<a href="$links[2]">$titles[2]< ...

Can you provide guidance on how to use Javascript to submit a form specifically when the input name is labeled as "submit"?

Query: How can I use Javascript to submit a form when one of the form inputs is named submit? Scenario: I need to send users to another page using a hidden HTML form. Unfortunately, I cannot modify the names of the inputs in this form because it needs to ...

Transferring information between components and pages within Next.js involves the passing of data

I currently have an index page set up like this: getServerSideProps(){ //Making two API calls here api1() api2() return{ props:{data:gotDataApi1, data2:gotDataApi2} } } The data retrieved from these APIs is then passed to a component within the index pag ...

What could be causing my AJAX form to refresh the page upon submission?

I have been working on a basic Follow/Unfollow system, and although the functionality is working correctly in terms of inserting and deleting rows when following/unfollowing, I'm facing an issue where the page refreshes every time despite using e.prev ...

Key Assignment in Vue FireStore - Potential Undefined Object Situation

My goal is to assign Firestore data, passed through props, to a reactive proxy object in Vue. However, I am encountering an error that says: Object is possibly 'undefined'. (property) fireStoreData: Record<string, any> | undefined To strea ...

Modifying Selectize Ajax data in real-time

How can the student_id be changed each time the modal is opened? This is the code: $('#relationshipModal input[name=existing_user]').selectize({ valueField: 'id', searchField: 'name', options: [], create: fal ...

Preventing access to drives and desktop until the mandatory HTML form is completed

Looking to develop a webpage in JSP that will automatically open whenever my system is started. Users will be required to fill out a form on this page before proceeding further. If they attempt to bypass filling out the form, they should not have access ...

Is there a way to transfer a significant volume of data from one webpage to another without relying on the POST

Currently, I am utilizing a web server framework that exclusively operates with GET requests. Presently, my task involves transferring a substantial volume of data (specifically the text content in a textarea) inputted by users onto another page where it i ...

Converting function arguments into key/value pairs: A simple guide

I am looking for a way to achieve the following in NodeJS: a = 10 b = 20 c = 30 d = 40 ...... ...... function createObject(a, b, c, d, ....) => { // This function is expected to return an object. // return { a : 10, b : 20 ...

Implement the map function to validate every input and generate a border around inputs that are deemed invalid or empty upon button click

Currently, I'm in the process of developing a form with multiple steps. At each step, when the next button is clicked, I need to validate the active step page using the map function. My goal is to utilize the map function to validate every input and ...

Am I on the right track with incorporating responsiveness in my React development practices?

Seeking advice on creating a responsive page with React components. I am currently using window.matchMedia to match media queries and re-rendering every time the window size is set or changes. function reportWindowSize() { let isPhone = window.matchMed ...

Expanding cards with Material-UI and React seems to be a challenge when using an expander

I've recently integrated a Card component into my project, sourced from material-ui's official website. However, I'm encountering an issue where the CardHeader does not expand upon clicking. This is the structure of my Component : import ...

What is the best way to send parameters to a callback function in a jQuery $.getJSON method?

Currently, I am attempting to utilize jQuery to access a custom API using Ajax/$.getJSON. In my code, I am trying to send a specific value to the Ajax callback method, but I am encountering an issue where this value is not being properly passed and instea ...

Restart the calling process using NodeJS command

Is there a way to automatically restart the calling process in case certain events occur while querying a database? I want the process to start over if specific conditions are met. ...

Having trouble converting data back to JSON format after using JSON.parse in an ejs file with node and express

I'm retrieving data from an external API on my server, then attempting to pass that data to an ejs file using JSON.stringify(data), and trying to read the data in the ejs file by parsing it with JSON.parse(data). However, I am encountering issues wher ...

Preserve information on page reload in AngularJS

I am currently working on an AngularJS application with Spring REST as the backend. My experience with AngularJS is quite new. Within my UI page, I have a table displaying a list of objects with an edit button for each record. Clicking the edit button ope ...

Transmit information to PHP script using JavaScript

I am facing an issue with sending form data to another PHP file. While the process is working, the problem lies in the fact that once the data is submitted, the page does not redirect to the specific page as intended. It seems like it doesn't work th ...

Making Cross-Origin Requests using jQuery's Ajax function and PHP

I've attempted numerous times to make this function properly, but for some reason, I just can't seem to figure it out. Initially, everything was working flawlessly for a few requests, and then out of the blue, it stopped functioning. Below is t ...

Comparison between swiping with two fingers and dragging with one finger on iOS devices

Within my application, I have created a custom Canvas class that extends from a UIView which utilizes touchesBegan: withEvent:, touchesMoved: withEvent:, and touchesEnded: withEvent: methods for drawing on the canvas. Additionally, I aim to implement a fun ...