Reputation: 8119
I am using superagent from Node.
For a simple request like this, how can I fetch/request only the headers of the page, not the full-content ?
request.get('https://google.com')
.then((res) => {console.log(res.headers);})
.catch(err=> console.log(err.status));
I tried to find in the documentation and Google but couldn't find anything on it.
Upvotes: 0
Views: 986
Reputation: 8119
Thanks to @CBroe for pointing me to the right direction.
For the visitors from the future ...
What you need is to replace GET
request with HEAD
request.
For example, in my case, it would be:
const request = require('superagent');
request
.head('https://google.com')
.then((res) => {console.log(res.headers);})
.catch(err=> console.log(err.status));
Upvotes: 1