【问题标题】:Does WebAPI fetch follow redirects?WebAPI 获取是否遵循重定向?
【发布时间】:2018-03-31 17:25:35
【问题描述】:

fetch 是否遵循 HTTP 30x 重定向?

【问题讨论】:

标签: javascript http web


【解决方案1】:

是的。 Check this

检查响应是否来自重定向请求 就像在 Response 对象上检查这个标志一样简单。

 if (response.redirected) {
   //...
 }

您可以禁用它:

fetch("awesome-picture.jpg", { redirect: "error" }).then(function(response) {
  //some stuff
}).then(function(imageBlob) {
  //some other stuff
});

【讨论】:

    猜你喜欢
    • 2021-04-29
    • 2012-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多