Все выполняется в порядке при первом запуске. Но это дает обратный вызов, уже названный ошибкой во втором прогоне. Благодарю.ошибка обратного вызова при втором нажатии
Server Side Код:
async.waterfall([
function(pcallback) {
//var mykeyword = "";
//resultset="";
app.post('/login',function(req,res){
Keyword=req.body.keyword;
Category=req.body.category;
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:9000'); // Website you wish to allow to connect
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); // Request methods you wish to allow
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type'); // Request headers you wish to allow
res.setHeader('Access-Control-Allow-Credentials', true); // Set to true if you need the website to include cookies in the requests sent // to the API (e.g. in case you use sessions)
console.log("\nKeyword = "+Keyword+", Category is "+Category); //till here everything is executing fine on 2nd run
//mykeyword=user_name;
res.end("yes");
pcallback(null, Keyword);
});
},
function(mykeyword, pcallback) {
Keyword=mykeyword;
console.log("\n\nmy keyword ",Keyword)
callAWS(Keyword, function(response){
// Here you have access to your variable
console.log(response);
pcallback(null,response);
})
}, function(resultset, pcallback){
app.use(function (req, res) {
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:9000/data'); // Website you wish to allow to connect
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); // Request methods you wish to allow
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type'); // Request headers you wish to allow
res.setHeader('Access-Control-Allow-Credentials', true); // Set to true if you need the website to include cookies in the requests sent // to the API (e.g. in case you use sessions)
//console.log(resultset)
//res.send(resultset)
//console.log(resultset);
res.send(resultset)
res.end();
});
pcallback();
}], function(err){
if(err) return(pcallback(err));
console.log("I'm Done !");
});
Со стороны клиента, у меня есть текстовое поле и кнопка, которая запрашивает определенное ключевое слово.
Спасибо, миллион. Это решило проблему. –