简体   繁体   English

Azure移动服务插入覆盖问题

[英]Azure Mobile Service Insert Override Issue

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. 请求“ POST / tables / Tree”已超时。 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 另外我在ios客户端应用中遇到以下错误

Domain=com.Microsoft.WindowsAzureMobileServices.ErrorDomain Code=-1302 "Error: The request has timed out. .... Domain = com.Microsoft.WindowsAzureMobileServices.ErrorDomain代码= -1302“错误:请求已超时。

But debug logs shows all part of the code successfully executed as expected. 但是调试日志显示了按预期成功执行的所有代码部分。

How can I solve this issue? 我该如何解决这个问题?

Thanks in advance... 提前致谢...

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. 覆盖request.execute函数的成功回调后,默认行为(将响应返回给调用者)将不再执行。 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);
            });
        }
    });
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM