1

I am getting

unable to determine the domain name

error when using https.get in node.js application.

My code is below:

const options = {
                    hostname: hostname,
                    port: 443,
                    path: remotePDFFilePath,
                    method: 'GET'
                };
https.get(hostname + remotePDFFilePath, res => {
    res.setEncoding("base64");
    let body = "";
    res.on("data", data => {
        body += data;
    });
    res.on("end", () => {
        callback(null, {
            status: 1,
            response: body.toString('base64')
        });
    });
});

I have tried searching Google and StackOverflow but did not find any relevant information. I tried changing https module with http but got he same error.

The value for hostname is "subdomain.domain.org" and the value for remotePDFFilePath is "/January Folder/Last, First DocID.pdf".

6
  • Could you inspect the values of hostname and remotePDFFilePath in the debugger, or log those into the console and post the value here? Commented Aug 29, 2018 at 9:47
  • @RamizWachtler I have edited and updated my question with the values. Commented Aug 29, 2018 at 10:01
  • 1
    Could you try https.get(options, res => {...}) instead of https.get(hostname + remotePDFFilePath, res => {...}) Commented Aug 29, 2018 at 10:14
  • Although not directly an answer to my question, as I am already using TRY CATCH, but a relevant one: stackoverflow.com/questions/34933229/… Commented Aug 29, 2018 at 10:35
  • @RamizWachtler interestingly, following your latest suggestion fixed my issue. Now https is connecting. I wonder what could have been the logic behind that. Commented Aug 29, 2018 at 10:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.