在html中显示$http.result正文(使用ExpressJS和angular)

在html中显示$http.result正文(使用ExpressJS和angular),express,Express,我是expressjs的新手 需要在html中显示jsnArry。能够看到res.on('data')或res.on('end')中的chunk/jsnArry json,但不知道如何将其传递到index.html 尝试了res.render/res.send(jsnArry),但没有任何效果。提前谢谢你的帮助 app.use('/index', function(req, res){ var getReq = http.request(options, function(res) {

我是expressjs的新手

需要在html中显示jsnArry。能够看到res.on('data')或res.on('end')中的chunk/jsnArry json,但不知道如何将其传递到index.html

尝试了res.render/res.send(jsnArry),但没有任何效果。提前谢谢你的帮助

app.use('/index', function(req, res){
    var getReq = http.request(options, function(res) {
    console.log('STATUS: ' + res.statusCode);
    console.log('HEADERS: ' + JSON.stringify(res.headers));
    res.setEncoding('utf8');
    res.on('data', function (chunk) {
      jsnArry += chunk; 
    });

     res.on('end', function (chunk) {
         res.body = jsnArry;   
     });
    });
//  res.sendFile(path.join(_dirname, '/html', 'index.html'));

});

您是否尝试过将其作为静态文件,并使用res.json(data)简单地发送结果?感谢您的建议,我尝试过它不起作用。。我通过在res.on('end')方法中调用next将值传递给另一个中间件进行了修复