How do I check to see if a URL exists without pulling it down? I use the following code, but it downloads the whole file. I just need to check that it exists.
ap
require into functions is wrong way in Node.
Followed ES6 method supports all correct http statuses and of course retrieve error if you have a bad 'host' like fff.kkk
checkUrlExists(host,cb) {
http.request({method:'HEAD',host,port:80,path: '/'}, (r) => {
cb(null, r.statusCode >= 200 && r.statusCode < 400 );
}).on('error', cb).end();
}