0
API呼び出しから応答を受け取った後に関数を呼び出そうとしています。ここでは、この2つのAPIを扱うスラックAPI
function saveScore(bot,result,message){
getFirstScore(bot,result).then(function(fscore){ //API -1
if(fscore){
getSecondScore(bot,result,null).then(function(sscore){ //API -2
if(fscore && sscore){
var finalScores = "First score is " + fscore + " :innocent:" + "\n Second score is "+ sscore +" :blush: ";
var remindAttachment = util.reminderAttachment("",finalScores);
listAllScores(bot,message,remindAttachment);
}
},function(error){
console.log('sscore error: ' + error);
});
}
},function(error){
console.log('fscore error: ' + error);
});
}
function listAllScores(bot,message,remindAttachment){
sendInstructions = function(response, convo){
convo.say(remindAttachment);
convo.say("Take it to the next level:");
convo.next();
setTimeout(function(){
listScores(bot,message);
},2000);
}
bot.startPrivateConversation(message, sendInstructions);
}
と同じように、私はlistScores(ボット、メッセージ)を呼び出したいです。以降の機能convo.say(remindAttachment);。しかし今はロード中listScores(bot、message);最初はです。だから、私はタイムアウト(良いアプローチではない)を設定していますlistScores(bot、message);いつか後でをロードしてください。
もっと良い方法がありますか?listScores(bot、message);以降の機能convo.say(remindAttachment);
編集
function listAllScores(bot,message,remindAttachment){
sendInstructions = function(response, convo){
convo.say(remindAttachment, function(error){
console.log("error ::::::::::::::::::::",error);
if(error!=null) {
listScores(bot,message);
}
});
}
bot.startPrivateConversation(message, sendInstructions);
}
おかげ。コールバックを使用しようとしましたが、そのコールバック関数が呼び出されていません。 – NNR
convo.say関数のスニペットを教えていただけますか? –