Friday 14 April 2017

request follow redirection without post data

I'm using request.js for http request in Node.js.

request({
  method: 'POST',
  uri: 'http://www.example.com/getData',
  followAllRedirects: true,
  followOriginalHttpMethod: true,
  json: true,
  form: {
    id: 1,
    msg: 'Test data',
  },
}, (err, res, body) => {})

Let's say when I post { id: 1, msg: 'Test data' } to http://test.example.com/getData, proxy will redirect to http://us.example.com/getData.

The codes above do redirect to http://us.example.com/getData, but How can I set the redirection with post data?



via huachengzan

No comments:

Post a Comment