Skip to content Skip to sidebar Skip to footer

Http Get Request (node) Returns 501

I'm testing fake HTTP requests on Node. But I get the same result (501) on the headers defining GET, POST methods or 'FOO'. I don't understand the output. Can someone give me a hin

Solution 1:

The options object has no uri key, you should use hostname.

Also, do not specify the protocol inside the host, use the key protocol.

Your object should be:

const options = {
    hostname: 'www.google.com', 
    protocol: 'https:',
}

Remember that to use https you need to include the right module:

const https = require('https');

Post a Comment for "Http Get Request (node) Returns 501"