Fetch API HTML Sample

Available in Chrome 42+ | View on GitHub | Browse Samples

Background

This sample shows how the Fetch API can retrieve and deserialize a JSON-encoded Object.

Live Output


JavaScript Snippet

fetch('users.json').then(function(response) {
  return response.json();
}).then(function(json) {
  ChromeSamples.log('Parsed JSON from the response:', json);
}).catch(function(ex) {
  ChromeSamples.log('Parsing failed:', ex);
});