XHR/Fetch Breakpoints
You'll learn how to pause execution automatically when network requests match a URL pattern, letting you inspect request details and response handling in real-time.
What Are XHR/Fetch Breakpoints?
XHR/Fetch breakpoints allow you to tell the debugger: "Stop execution whenever my code makes a network request to a URL containing this text." Instead of manually setting breakpoints in every callback or async function that handles responses, you intercept the request itself—before it fires, as it completes, or both.
This is especially powerful when debugging API integrations, authentication flows, or third-party service calls where you need to see the exact moment data is sent or received.
Why This Matters
Think of it like a security checkpoint for network traffic. Rather than chasing down every function that might fetch user data, you set one breakpoint for any URL containing /api/user and catch them all. When the breakpoint triggers, you can inspect:
- Request payloads – What data is being sent?
- Headers – Are auth tokens correct?
- Timing – When exactly does the request happen in your execution flow?
- Response handling – What happens immediately after the data arrives?
How It Works
In Chrome DevTools, you open the Sources panel, navigate to the XHR/Fetch Breakpoints section, and add a URL pattern (like api/login or graphql). Any XMLHttpRequest or fetch() call matching that pattern will pause execution, dropping you into the debugger at the point the request is made.
You now have full debugging context: call stack, scope variables, and the Network panel showing the request details.
Key Takeaway: XHR/Fetch breakpoints let you intercept and debug network requests by URL pattern, eliminating guesswork about when and how API calls execute.