Fetch API

The Fetch API provides an interface for fetching resources (e.g., across the network.)

Uses

  • Request data from server
  • Post data to a server
  • Replace XMLHttpRequest();

Example

// url (required), options (optional)
fetch('/foo/bar', { method: 'get' }).then(function(response) {
        //Do something with your response
}).catch(function(err) {
        //Handle any errors here
});