SuperAgent -- 仅获取 headers
SuperAgent -- Fetching only the headers
我正在使用来自 Node 的 superagent。
对于这样一个简单的请求,我如何才能 fetch/request 只有页面的 headers 而不是 full-content ?
request.get('https://google.com')
.then((res) => {console.log(res.headers);})
.catch(err=> console.log(err.status));
我试图在文档中找到 Google 但找不到任何内容。
感谢@CBroe 将我指向 the right direction。
致未来的访客 ...
您需要用 HEAD
请求替换 GET
请求。
例如,在我的例子中,它将是:
const request = require('superagent');
request
.head('https://google.com')
.then((res) => {console.log(res.headers);})
.catch(err=> console.log(err.status));
我正在使用来自 Node 的 superagent。
对于这样一个简单的请求,我如何才能 fetch/request 只有页面的 headers 而不是 full-content ?
request.get('https://google.com')
.then((res) => {console.log(res.headers);})
.catch(err=> console.log(err.status));
我试图在文档中找到 Google 但找不到任何内容。
感谢@CBroe 将我指向 the right direction。
致未来的访客 ...
您需要用 HEAD
请求替换 GET
请求。
例如,在我的例子中,它将是:
const request = require('superagent');
request
.head('https://google.com')
.then((res) => {console.log(res.headers);})
.catch(err=> console.log(err.status));