我的云代码中有三种方法,所有方法都调用Parse.Cloud.HttpRequest。所有这些方法,返回一个回调,我正在回调中执行下一个函数。这似乎给了我一个代码124和超时错误。无论如何都要优化这段代码吗?
以下是一个如何调用它们的示例:
findMetroId(latitude,longitude,function(mI){
mId = mI;
//first httpRequest
getArtistId(artist,function(aI){
//second httpRequest
id = aI;
console.log("Testing values in main function: id = " + id + " mId = " + mId);
compareDates(mId,id,latitude,longitude,function(myLink,status){
//third httpRequest
console.log("Is concert near? " + status);
console.log("User to be Yo'd is " + username);
if(status === true){
console.log("Link is " + myLink);
sendYo(username,myLink);//fourth httpRequest
}else{
//No concert is near to user
sendYo(username,'http://concertalert.parseapp.com/no.html');
}
});
});
});