What is the main difference between using fetch() and XMLHttpRequest for making HTTP requests?
The fetch() API provides a more modern and cleaner interface compared to XMLHttpRequest. Key differences include: 1) fetch() returns a Promise, making it easier to handle asynchronous operations with async/await, 2) It has a more intuitive API design, 3) Better error handling through Promise rejection, 4) Simpler request configuration through the Request and Headers interfaces. However, fetch() won't reject on HTTP error status codes (only network errors), which is something to be aware of when implementing error handling.