Docs

Everything You Need to Know

Fetch

Intro

Fetch is a new API created by the WHATWG as a simplified and lower level alternative to XHTTP requests. Fetch is built on the concept of asynch operations, something that was not taken into consideration at the time that Ajax was developed. Fetch uses promises by default. It also provides a simle and consistent interface to doing the things that Ajax requires with many lines of code. At the same time, it provides ways of customizing headers, etc. for more specialized needs. Below is an example of Fetch:

fetch('./some/url')
  .then(function(response) {
    return response.json();
  })
  .then(function(data) {
    console.log(data);
  })
  .catch(function(err){
    console.log(err);
  });

This is currently supported in the latest versions of browsers. ChocolateChip-UI provides a polyfill for older browsers so you can use it today with confidence.

Please read the section on Use to learn how to use it in your app.