What's the key diff between fetch and xhr type for API requests? or Can someone explain the diff betw

18 Replies, 989 Views

Honestly, the diff between fetch and xhr type is mostly syntax and modernity.

fetch = shorter, cleaner, Promise-based.
xhr = longer, callback-based, but more features (like aborting requests).

fetch’s error handling *is* a bit quirky—it only fails on network errors, not bad status codes. You gotta handle that manually.

If you’re starting fresh, use fetch. If you’re maintaining old code, you might be stuck with XHR.

MDN has great examples for both!

Messages In This Thread



Users browsing this thread: 1 Guest(s)