nodejs check url is exist but don't download it
I found the npm packages urlExists
http
, they make a request and response with the body data
.
like the command curl -i url
I want don't download the body data
and know the url is exist.
nodejs check url is exist but don't download it
I found the npm packages urlExists
http
, they make a request and response with the body data
.
like the command curl -i url
I want don't download the body data
and know the url is exist.
You can use the HEAD
HTTP method:
The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response.
For example:
const fetch = require('node-fetch');
const response = await fetch('https://google.com', {
method: 'HEAD'
});
console.log(response.ok);
Of course this would rely on the web server properly implementing the RFC.