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

后端 未结 1 1712
梦如初夏
梦如初夏 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)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题