Does WebAPI fetch follow redirects?

前端 未结 1 1893
囚心锁ツ
囚心锁ツ 2021-01-18 01:05

Does fetch follow HTTP 30x redirects?

1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-18 01:54

    Yes. Check this.

    Checking to see if the response comes from a redirected request is as simple as checking this flag on the Response object.

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

    You can disable it:

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

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