How to use the head function from axios
Find comprehensive JavaScript axios.head code examples handpicked from public code repositorys.
axios.head sends an HTTP HEAD request to a server and retrieves the headers for a specified URL without retrieving the actual body of the response.
48 49 50 51 52 53 54 55 56 57
} async head(url, headers, config = {}) { config.headers = headers; config = this._checkConfig(config); return axios.head(url, config) } async options(url, headers, config = {}) { config.headers = headers;
51
418
30
GitHub: BOTCAHX/Hoream-MD
300 301 302 303 304 305 306 307 308 309
return kiyomasa } tio.sendFileUrl = async (jid, url, caption, quoted, options = {}) => { let mime = ''; let res = await axios.head(url) mime = res.headers['content-type'] if (mime.split("/")[1] === "gif") { return tio.sendMessage(jid, { video: await getBuffer(url), caption: caption, gifPlayback: true, ...options}, { quoted: quoted, ...options}) }
25
17
1
How does axios.head work?
axios.head is a method in the Axios library that sends an HTTP HEAD request to a server, which returns only the headers of the response without the body, and resolves with a Promise containing the response headers.
251 252 253 254 255 256 257 258 259
const link = $('#downloadButton').attr('href') const name = $('body > main > div.content > div.center > div > div.dl-btn-cont > div.dl-btn-labelWrap > div.promoDownloadName.notranslate > div').attr('title').replaceAll(' ','').replaceAll('\n','') const date = $('body > main > div.content > div.center > div > div.dl-info > ul > li:nth-child(2) > span').text() const size = $('#downloadButton').text().replace('Download', '').replace('(', '').replace(')', '').replace('\n', '').replace('\n', '').replace(' ', '').replaceAll(' ','') let mime = '' let rese = await axios.head(link) mime = rese.headers['content-type'] return { name, size, date, mime, link } }
6
5
2
237 238 239 240 241 242 243 244 245 246
For convenience, aliases have been provided for all common request methods. ##### axios.request(config) ##### axios.get(url[, config]) ##### axios.delete(url[, config]) ##### axios.head(url[, config]) ##### axios.options(url[, config]) ##### axios.post(url[, data[, config]]) ##### axios.put(url[, data[, config]]) ##### axios.patch(url[, data[, config]])
0
1
0
Ai Example
1 2 3 4 5 6 7 8
axios .head("https://example.com") .then((response) => { console.log(response.headers); }) .catch((error) => { console.log(error); });
This code sends a HTTP HEAD request to https://example.com, and then logs the response headers to the console. If there is an error, it will be logged to the console as well.
GitHub: resahdevv/Whats-Payment
764 765 766 767 768 769 770 771 772 773
* @param {*} quoted * @param {*} options */ client.sendFileUrl = async (jid, url, caption, quoted, options = {}) => { let mime = ""; let res = await axios.head(url); mime = res.headers["content-type"]; if (mime.split("/")[1] === "gif") { return client.sendMessage( jid,
0
0
1
+ 3 other calls in file