Paul Paul - 1 year ago 76
Node.js Question

Difference between Postman and a simple Http Request with superagent

I was wondering what's the difference between a simple POST request with superagent and a POST request with Postman.
Because Im trying to scrap a website, so I made a post request with Postman and everythings work fine, I got the result expected. But when I proceed a POST Http request with superagent, I got a 301 redirect.

There's a way to pass this problem in having the same result as Postman ?

Thanks in advance for your answer.

Answer Source

You should use redirects. Simple example:

const request = require('superagent');
const url = 'localhost:3000/example';
.send({msg: "hello"})
.redirects(1) //Add redirect functionality
.on('redirect', function(res) {
.end(function(err, res){
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download