请问data,end,erro这些事件的执行顺序是什么?因为有的时候回触发两次的callback导致程序崩溃。
代码如下:
const httpReq = http.get(options, function(res) {
res.on('data', function(data) {
htmlData.push(data);
htmlDataLength += data.length;
});
res.on('end',function(){
parseHtmlTitle(function(){
callback();
});
});
});
// 错误处理
httpReq.on('error', function (err) {
console.log (err);
callback();
});