I'm so confused right now. I've tried everything and I still cannot get this to work. Basically, I'm trying to get the HTML of a website, but it only works on Google. Here's my code:
const HttpClient = {
get: function(url, callback) {
var str = '';
var req = http.get(url, function(response) {
response.on('data', function (chunk) {
str += chunk;
});
response.on('end', function () {
callback(str);
});
}).on;
return true
}
}
HttpClient.get('http://www.google.com/index.html', (data) => {
console.log(data);
});
You can see that the URL I am providing is google.com. This is the only URL that I have found that actually returns something. Replacing the URL with anything else will make it not return anything.
Does anyone know why this is happening?
httpsmodule?