To make a HTTP HEAD request in JavaScript, you can use either the XMLHttpRequest
object or the fetch
API. Here are the code snippets for both approaches:
Using XMLHttpRequest:
index.tsx213 chars9 lines
Using fetch API:
index.tsx109 chars7 lines
Both approaches set the method to 'HEAD'
and send the request to the specified URL. The response headers can be accessed in the callback function of XMLHttpRequest
's onreadystatechange
event or as a property of the Response
object in the fetch
API's then
method.
gistlibby LogSnag