NodeJS http request output

左心房为你撑大大i 提交于 2019-12-08 04:05:35

问题


I have to do some http requests sequentially so i am using waterfall

Http request is taking around 2 seconds to respond.

returned response works in console.log(string) but undefined with response.end();

                    async.waterfall([
                    function(callback_wf_adnet){
                            ///Getting URLS for http requests.
                    },
                    function(adnetlist, callback_wf_adnet){
                                ///Switchman does http request
                            adData=switchman(element, ip, agent, req);

                            if (adData!='') {
                                callback_wf_adnet(null, adData);
                                return false;
                            }
                            return true;
                        });
                    },
                    function(adData, callback_wf_adnet){
                    console.log("ADDATA="+adData); /// Output works here
                        if(adData!='')
                        {
                            response.send(adData);  /// It doesn't work here
                        }

                        callback_wf_adnet(null, "just closing somethings");
                    }
                ], function (err, result) {
                });

来源:https://stackoverflow.com/questions/24766481/nodejs-http-request-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!