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);
});