Chrome dev tools fails to show response even the content returned has header Content-Type:text/html; charset=UTF-8
Why does my chrome developer tools show "Failed to show response data" in response when the content returned is of type text/html?
What is the alternative to see the returned response in developer tools?
Solution 1:
I think this only happens when you have 'Preserve log' checked and you are trying to view the response data of a previous request after you have navigated away.
For example, I viewed the Response to loading this Stack Overflow question. You can see it.
The second time, I reloaded this page but didn't look at the Headers or Response. I navigated to a different website. Now when I look at the response, it shows 'Failed to load response data'.
This is a known issue, that's been around for a while, and debated a lot. However, there is a workaround, in which you pause on onunload
, so you can view the response before it navigates away, and thereby doesn't lose the data upon navigating away.
window.onunload = function() { debugger; }
Solution 2:
For the ones who are getting the error while requesting JSON data:
If your are requesting JSON data, the JSON might be too large and that what cause the error to happen.
My solution is to copy the request link to new tab (get
request from browser)
copy the data to JSON viewer online where you have auto parsing and work on it there.
Solution 3:
As described by Gideon, this is a known issue with Chrome that has been open for more than 5 years with no apparent interest in fixing it.
Unfortunately, in my case, the window.onunload = function() { debugger; }
workaround didn't work either. So far the best workaround I've found is to use Firefox, which does display response data even after a navigation. The Firefox devtools also have a lot of nice features missing in Chrome, such as syntax highlighting the response data if it is html and automatically parsing it if it is JSON.
Solution 4:
As described by Gideon, this is a known issue.
For use window.onunload = function() { debugger; }
instead.
But you can add a breakpoint in Source tab, then can solve your problem.
like this:
Solution 5:
If you make an AJAX request with fetch
, the response isn't shown unless it's read with .text()
, .json()
, etc.
If you just do:
r = fetch("/some-path");
the response won't be shown in dev tools.
It shows up after you run:
r.then(r => r.text())