Node.js Request equivalent of jQuery AJAX .complete()

I am writing a Node.js API to register a user to another web app. The problem is, during registration process, the API that the Node app requested with request is 301 redirected to another API to complete the registration.

This problem can be solved if I’m using jQuery AJAX and wait for the .complete() callback to make sure the redirection is successful.

How can I accomplish this with Node.js request?


Apparently, it is caused by a redirect to a POST (non-GET) HTTP request, which is disabled by request at default. I should’ve enabled this option to follow any kind of HTTP request:

followAllRedirects: true

Details in this link: Follow redirect with node.js request

Leave a Reply

Your email address will not be published. Required fields are marked *