gpt4 book ai didi

javascript - 仅针对一项特定功能解析连接超时

转载 作者:行者123 更新时间:2023-11-28 08:33:51 25 4
gpt4 key购买 nike

下面是我的云代码,我试图在其中创建一个好友数据库,第一个和第三个函数都工作正常,但是 AcceptFriendRequest 函数超时,好像那里没有服务器,错误代码为 100。我我很迷茫,因为这种情况 100% 都会发生。感谢所有帮助。

Parse.Cloud.define("AddFriendRequest", function (request, response) {

var FriendRequest = Parse.Object.extend("FriendsIncoming");

var FRequest = new FriendRequest();

var user = request.user;

var query = new Parse.Query(Parse.User);
query.equalTo("username", request.params.username);
query.find({
success: function (people) {
if(people.length == 0)
{
response.success(-5);
return;
}

var person = people[0];
FRequest.set("OwnerID", user.id);
FRequest.set("TargetFriend", person.id);
FRequest.set("Status", 0);

var query = new Parse.Query("FriendsIncoming");
query.equalTo("OwnerID", user.id);
query.equalTo("TargetFriendID", person.id);
query.find({
success: function (results) {

if (results.length > 0) {
response.success(1);
return;
}
FRequest.save(null, {
success: function (Friend) {
response.success(2);
},
error: function (Friend, error) {
response.error(3);
}
});
response.error(-2);

},
error: function () {
response.error(-1);
}
});
}
,
error: function (Friend, error) {
response.error(-4);
}

});


});

Parse.Cloud.define("AcceptFriendRequest", function (request, response) {


var user = request.user;

var query = new Parse.Query("FriendsIncoming");
query.equalTo("OwnerID", user.id);
query.equalTo("TargetFriendID", request.params.TargetFriendID);
query.find({
success: function (results) {

if (results.length > 0) {

response.success(1);
return;
}
FRequest.save(null, {
success: function (Friend) {
response.success(2);
},
error: function (Friend, error) {
response.error(3);
}
});
response.error(-2);

},
error: function () {
response.error(-1);
}
});
});




Parse.Cloud.define("RetrieveFriends", function (request, response) {

var query = new Parse.Query("FriendsAccepted");
var results = [];


query.find().then(function (Friends) {
for (var i = 0; i < Friends.length; i++) {
results.push(Friends[i]);
}

// success has been moved inside the callback for query.find()
response.success(results);
}, function (error) {
// Make sure to catch any errors, otherwise you may see a "success/error not called" error in Cloud Code.
response.error("Could not retrieve Posts, error " + error.code + ": " + error.message);
});
});

最佳答案

似乎 AcceptFriendRequest 中的 FRequest 没有初始化...将其添加到函数内部。 parse.com 上的超时对于云功能是 15 秒,对于 afterSave 是 3 秒。他们可能会更改它,因为他们正在关闭

var FriendRequest = Parse.Object.extend("FriendsIncoming");
var FRequest = new FriendRequest();

关于javascript - 仅针对一项特定功能解析连接超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38299903/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com