Question

Hi I have written the following code in the "insert" operation.

function insert(item, user, request) {

item.createdDate = new Date();
item.updatedDate = new Date();

var node = { id: '', 
 textSize: 20,
 backColor: 'Blue',
 parentId: '' };

console.log('Root bubble initialized with default params: ', node);

request.execute({success:function()
{   
    node.parentId = item.id;

    var nodeTable = tables.getTable('Nodes');

    nodeTable.insert(node);

}});

}

But I am getting the following error in the log...

The request 'POST /tables/Tree' has timed out. This could be caused by a script that fails to write to the response, or otherwise fails to return from an asynchronous call in a timely manner.

Also I am getting the following error in the ios client app

Domain=com.Microsoft.WindowsAzureMobileServices.ErrorDomain Code=-1302 "Error: The request has timed out. ....

But debug logs shows all part of the code successfully executed as expected.

How can I solve this issue?

Thanks in advance...

Was it helpful?

Solution

You need to return a response to the caller. Once you override the success callback for the request.execute function, the default behavior (returning a response to the caller) doesn't execute anymore. You likely need something along the lines of the code below.

function insert(item, user, request) {

    item.createdDate = new Date();
    item.updatedDate = new Date();

    var node = { id: '', 
        textSize: 20,
        backColor: 'Blue',
        parentId: '' };

    console.log('Root bubble initialized with default params: ', node);

    request.execute( {
        success: function() {   
            node.parentId = item.id;
            var nodeTable = tables.getTable('Nodes');
            nodeTable.insert(node, {
                request.respond(statusCodes.CREATED, item);
            });
        }
    });
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top