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!
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!
