How to fetch (using Fetch API) only headers in Javascript, not the whole content?

后端 未结 1 1722
梦如初夏
梦如初夏 2021-01-11 19:16

Here I have this sample fiddle, where I try to get only the content-type header from a large image, using both XMLHttpRequest() an

相关标签:
1条回答
  • 2021-01-11 19:48

    You need to specify the method type of HEAD:

    fetch(url, {method: 'HEAD'})
    

    See updated fiddle

    0 讨论(0)
提交回复
热议问题