How to fix Fetch API GET request return an opaque response bug All In One
Status Code: 302
Found
fetch(`https://www.hulu.com/watch/78974b54-1feb-43ce-9a99-1c1e9e5fce3f`, {mode: "no-cors"})
.then(function (response) {
console.log(`response`, response);
// The API call was successful!
return response.text();
})
.then(function (html) {
// This is the HTML from our response as a text string
console.log(html);
})
.catch(function (err) {
// There was an error
console.warn('Something went wrong.', err);
});
solutions
URL 重定向
https://www.hulu.com/watch/78974b54-1feb-43ce-9a99-1c1e9e5fce3f
Response Headers
✅
Location: /movie/my-favorite-girlfriend-78974b54-1feb-43ce-9a99-1c1e9e5fce3f?entity_id=78974b54-1feb-43ce-9a99-1c1e9e5fce3f
fetch(`https://www.hulu.com/watch/78974b54-1feb-43ce-9a99-1c1e9e5fce3f`, {mode: "no-cors"})
.then(function (response) {
console.log(`response`, response.headers);
// The API call was successful!
return response.text();
})
.then(function (html) {
// This is the HTML from our response as a text string
console.log(html);
})
.catch(function (err) {
// There was an error
console.warn('Something went wrong.', err);
});
demos
(? 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!
Response
https://developer.mozilla.org/en-US/docs/Web/API/Response
Headers
https://developer.mozilla.org/en-US/docs/Web/API/Headers
refs
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
https://stackoverflow.com/questions/77338662/programmaticaly-get-movie-name-from-hulu-url
©xgqfrms 2012-2021
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 ?️,侵权必究⚠️!
- response request opaque return Fetchresponse request opaque return response header fetch api returned response server问题 response request requested returned github gitee requested returned access unable quot requested returned pycurl response request axios upstream_response_time time request_time response response request amp