User Agents

Web browsers and everyday web tech, explained

Debug API Responses in Chrome: Step-by-Step

· 6 min read · Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

When an API call returns something unexpected, the fastest way to find the problem is to inspect the actual request and response in Chrome's DevTools. This guide shows you how to open the Network panel, filter for API calls, read status codes, headers, and JSON payloads, and use console errors to trace issues. You'll need Chrome (any recent version) and a page that makes API calls—either your own code or a third-party site.

What You'll Need

  • Google Chrome (desktop version)
  • A web page that triggers the API call you want to debug
  • Basic familiarity with HTTP status codes (e.g., 200, 404, 500)

Step-by-Step

  1. Open DevTools. Right-click anywhere on the page and select Inspect, or press F12 / Ctrl+Shift+I (Windows/Linux) or Cmd+Option+I (Mac).
  2. Go to the Network tab. Click the Network tab at the top of DevTools. If you don't see it, click the >> arrow to reveal more tabs.
  3. Preserve logs (optional). Check the Preserve log checkbox if the page reloads or redirects before the API call. This keeps previous requests visible.
  4. Filter for XHR/Fetch. In the filter bar, click Fetch/XHR to show only API requests (not images, CSS, or scripts). This is the fastest way to isolate your API calls.
  5. Trigger the API call. Perform the action that makes the request—click a button, submit a form, or reload the page. Watch the Network list populate.
  6. Click the request. Find the request you want to debug (it usually shows the API URL or a name like users or getData). Click it to open the details pane.
  7. Check the Headers tab. Look at General for the Request URL and Request Method (GET, POST, etc.). Scroll to Response Headers to see Content-Type and status. Request Headers show what the browser sent (e.g., Authorization tokens).
  8. Check the Response tab. Click Response to see the raw body. If it's JSON, it will be formatted. If it's empty, the server sent nothing.
  9. Check the Preview tab. For JSON responses, Preview shows a collapsible tree view. Expand objects to inspect nested values.
  10. Look at the status code. The status (e.g., 200 OK, 404 Not Found) appears next to the request name. A 4xx or 5xx indicates an error—read the response body for an error message.
  11. Use the Console for errors. Switch to the Console tab. If the API call failed, you'll often see a JavaScript error like Failed to fetch or the actual error object. Click the error to see the stack trace.
  12. Inspect the timing. In the Network tab, click the Timing tab (inside the request details). This shows how long each phase took—DNS, connection, TLS, waiting, and downloading. A long Waiting (TTFB) suggests a server-side delay.
  13. Copy the response as cURL (optional). Right-click the request in the Network list, select Copy > Copy as cURL. Paste it into a terminal to reproduce the request outside the browser—useful for testing with different headers.
  14. Use the Search feature. Press Ctrl+F (or Cmd+F) in the Network tab to search for a specific string in all responses, like an error code or a field name.

Common Mistakes

  • Forgetting to filter. Without the Fetch/XHR filter, you'll see dozens of unrelated requests and miss the API call.
  • Looking at the wrong request. Some pages make multiple calls to the same endpoint. Check the request method and payload to confirm you're inspecting the right one.
  • Ignoring the request headers. A missing or expired Authorization header is a common cause of 401 errors. Always verify what the browser actually sent.
  • Only reading the status code. A 200 doesn't mean the data is correct—it only means the server responded. Inspect the body for error messages or unexpected values.
  • Not preserving logs. If the page redirects, the original request disappears unless you checked Preserve log.
  • Misreading JSON. If the response is a string, not an object, check the Content-Type header. It might be text/plain, not application/json.

Tips

  • Use the Network panel while recording. Keep it open and perform the action slowly—this helps you associate the click with the request.
  • Clear the log before testing. Click the Clear icon (circle with a slash) to remove old requests, so you only see new ones.
  • Enable 'Disable cache' for testing. In the Network tab, check Disable cache to ensure you're not seeing a cached response.
  • Use the 'Initiator' column. Right-click the column headers and enable Initiator to see which JavaScript function triggered the request—useful for tracing code.
  • Export the HAR file. Right-click anywhere in the Network list and select Save all as HAR with content. This captures all requests and responses, which you can share with a backend developer or replay in other tools.
  • Test with different network conditions. Use the Network throttling dropdown to simulate slow connections and see if timeouts are the issue.

Troubleshooting

No requests appear in the Network tab. Make sure you're on the correct page and that the API call actually fires. Try reloading the page or clicking the button again. If still nothing, check if the call is delayed or triggered by a scroll event.

The request shows a red status (e.g., 500). This is a server error. Look at the response body—it often contains a stack trace or error message. If it's empty, try reproducing the request with cURL to see if the error persists outside the browser.

The response is blank or truncated. Some servers gzip responses. Chrome automatically decompresses them, but if you see gibberish, check the Content-Encoding header. Also, large responses may be truncated in the Preview tab—use the Response tab instead.

The status is 200 but the data is wrong. Compare the response with what you expect. Check if the request parameters (query strings, request body) are correct. Use the Payload tab to see what was sent.

You see a CORS error in the console. This means the server didn't include the correct Access-Control-Allow-Origin header. Look at the response headers in the Network tab to confirm. This is a server-side fix, not something you can change in Chrome.

The API call works in a new tab but not on the page. The issue is likely the request headers (like Origin or Referer) or cookies. Compare the cURL request from the working tab vs. the failing one.

Frequently Asked Questions

How do I see the full URL of an API request?

Click the request in the Network tab, then go to the Headers tab. Under General, you'll see the full Request URL. You can also hover over the request name in the list to see the URL as a tooltip.

Why do I see a 304 Not Modified status?

That's not an error. It means the browser used a cached version of the response. To see the actual response, check Disable cache in the Network tab and reload.

Can I debug API calls from a mobile device?

Yes. Connect your phone via USB and enable USB debugging, then open DevTools on your computer and select the device from the remote target list. The Network tab will show the mobile browser's requests.

What does 'Pending' mean in the Network tab?

The request is still waiting for a response. If it stays pending, the server may be slow or the request may be blocked. Check the Timing tab to see if it's stuck in a specific phase.

How do I copy the response body to a file?

Right-click the request, select Copy > Copy response, then paste it into a text editor. Alternatively, save the entire HAR file and extract the response from there.

Why does the response show as 'Failed to load response data'?

This happens when the response is not available, often because the request was blocked (e.g., by CORS) or the browser didn't receive a body. Check the status code and console for more details.