Fetch
fetch() allows you to make network requests similar to XMLHttpRequest (XHR). The main difference is that the Fetch API uses Promises, which enables a simpler and cleaner API, avoiding callback hell and having to remember the complex API of XMLHttpRequest. The Fetch API has been available in the Service Worker global scope since Chrome 40, but it'll be enabled in the window scope in Chrome 42. There is also a rather fetching polyfill by GitHub that you can use today. If you've never used Promises before, check out Introduction to JavaScript Promises. Basic Fetch Request Let's start by comparing a simple example implemented with an XMLHttpRequest and then with fetch . We just want to request a URL, get a response and parse it as JSON. XMLHttpRequest An XMLHttpRequest would need two listeners to be set to handle the success and error cases and a call to open() and send() . Example from MDN docs . function reqListener () { var data = JSON . parse ( th...