昨日この質問を投稿しました:https://stackoverflow.com/questions/25919099/how-do-i-use-callback-to-solve-authentication-issue
基本的に、ログイン要求からの応答を待ってから、チェックイン要求に移動します。それ以外の場合、チェックイン要求は認証エラーである 401 を返します。
現在、step、wait.for、async などのライブラリを使用して応答を待機しようとしています。async.series を使用してこのコードを試していますが、unexpected token function
エラーが発生していますfunction two()
function checkin() {
async.series[(
function one() {
agent1
.post(login-url)
.type('form') // send request in form format
.send({
username: username,
password: password
})
.end(function(err, res) {
console.log("response for login is ", res.statusCode, " ", res.message);
});
}
function two() {
for (var i = 0; i < count; i++) {
if (validatePayment(rows[i].Payment) == true && validateMobile(rows[i].Mobile) == true) {
console.log("inside validation");
agent1
.post(checkin-url)
.send({
phone: rows[0].Mobile,
outlet: outletID
//outlet: "rishi84902bc583c21000004"
})
.end(function(err, res) {
console.log("response for checkins is ", res.statusCode, " ", res.message);
});
)];
}
}
}
// });
}