I'm trying to get the HTML of a website using restler. But when I try to get the relevant part of result, I always get the error,
"TypeError: Cannot read property 'rawEncoded' of undefined".
'rawEncoded' sometimes is 'res'. I think it changes based on processing time.
I'm trying to get result.request.res.rawEncode from restler get result.
My function:
var rest = require('restler');
var loadHtmlUrl = function(weburl) {
var resultstr = rest.get(weburl).on('complete', function(result) {
var string = result.request.res.rawEncode;
return string;
});
return resultstr;
};
Then:
var htmlstring = loadHtmlUrl('http://google.com');
Maybe restler is the entirely wrong way to go. Maybe I don't understand it completely. But I'm definitely stuck...
Thanks!