Request Problems using superagent

2

I'm trying to request using the library superagent on my server nodejs , I'm following the documentation, however, is not working. Here's my code nodejs :

var express = require('express');
var app = express();
var request = require('superagent');

app.set('port', (process.env.PORT || 5006));    

request
   .get('http://www.google.com.br')
   .end(function(err, res){

   });

app.listen(app.get('port'), function() {
  console.log('Node app is running on port', app.get('port'));
});

Follow the documentation link for superagent :

link

Can anyone help me with what I'm doing wrong in this request ?

    
asked by anonymous 08.01.2016 / 19:56

1 answer

2

You can use this:

app.get('/', function(req, resp) {
    request("http://www.google.com.br", function(err, res){ 
        resp.send(res.body);
    });
});

When you use resp.send(res.body); Express automatically adds HTTP headers and you do not need to do this separate.

    
09.01.2016 / 11:50