1

I have questions similar to this one such as: curl command equivalent in nodejs

However I can not make a equivalent cURL in NodeJS to the next link:

http://link.novemberfirst.com/ls/click?upn=xv2uBCiA-2BCPo8h2-2F2dXgSrKknBTgupgeogOdcsRpYXuG4cjYbJP1rkCCJ1zjXTj38aokCt-2BgUcrLMVeDJ0JrFznoH-2B4JC2bxKIUkkwWGvQPWZcW89yPA45cRI4YcN4kxIWOMamgXF7h0x-2BEumL4yC4cDPD6ib2Q-2FupSBTSJJvOohq9d3QApg3ktPsAr3s71dx8_f_jH2AkQSF6IE8lczSdagr9wUDFh2rSjc-2FDARefysokTdqaEnXNbSWSyYzYz4pIdy3KyzKI2WI84SAhUWA6Ysrwbu-2FEyv-2FLVj28UDJ96u9m0SfvfLMgVTTOypSpnfzJhz8HBp-2BErWzxw-2BHQBTWKJQCCsahFPt7FAp2yflzLocMroRH-2Blyqk-2Be61Q84U19yBAQ11beRliiLdNHnzJwd88-2FGbgPTIQoQi0xlVBQxVt08NyA-3D

I have tried with request library and lib-curl and in both cases I am getting an error in the response. However curl in unix works perfectly and returns me

<a href="https://app-uat.novemberfirst.cloud.ec//#/public/reset-password/208100002/61849181%40abc.com/F1PMDcC05gYhlqh82UDnl183/dan/">Found</a>
Patrick Vibild
  • 405
  • 1
  • 3
  • 16

2 Answers2

1

I think the issue here is that the server is returning a 302 status code, but the Location header it's sending back doesn't exist.

The request library is following the 302 link (this is the default behaviour for GETs) and this is resulting in a timeout.

You can switch off this behaviour to get the same response as curl like so:

const request = require('request');

const options = {
    method: "GET",
    headers: {
        'User-Agent': 'node-request'
    },
    followRedirect: false,
    followAllRedirects: false,
    url: 'http://link.novemberfirst.com/ls/click?upn=xv2uBCiA-2BCPo8h2-2F2dXgSrKknBTgupgeogOdcsRpYXuG4cjYbJP1rkCCJ1zjXTj38aokCt-2BgUcrLMVeDJ0JrFznoH-2B4JC2bxKIUkkwWGvQPWZcW89yPA45cRI4YcN4kxIWOMamgXF7h0x-2BEumL4yC4cDPD6ib2Q-2FupSBTSJJvOohq9d3QApg3ktPsAr3s71dx8_f_jH2AkQSF6IE8lczSdagr9wUDFh2rSjc-2FDARefysokTdqaEnXNbSWSyYzYz4pIdy3KyzKI2WI84SAhUWA6Ysrwbu-2FEyv-2FLVj28UDJ96u9m0SfvfLMgVTTOypSpnfzJhz8HBp-2BErWzxw-2BHQBTWKJQCCsahFPt7FAp2yflzLocMroRH-2Blyqk-2Be61Q84U19yBAQ11beRliiLdNHnzJwd88-2FGbgPTIQoQi0xlVBQxVt08NyA-3D',
};

function callback(error, response, body) {
    if (error) {
        console.error("Error:", error);
    } else {
        console.log("Response (status code):", response.statusCode);
        console.log("Response (body):", body);
    }
}

request(options, callback);
Terry Lennox
  • 29,471
  • 5
  • 28
  • 40
0

I am not sure i get your question correctly but it seems you want to translate a cURL to to url that you'd call in nodejs. You can use postman to do that if you are doing it yourself. Goto code section there and paste in your cURL and translate to option of your choice.

Saurabh Agrawal
  • 162
  • 2
  • 13