“A Promise-based mechanism for programmatically making web requests in the browser.” Replaces most uses of XMLHttpRequest in traditional web applications.
See more links at the end of this post.
Example 1 (run in console):
fetch('http://mindymcadams.com/index.html').then(response => {
return response.text();
}).then(text => {
console.log(text);
});
Example 2 (run in console with animals.json file in same dir as the currently open page):
fetch('animals.json').then(response => {
return response.json();
}).then(json => {
console.log(json);
});
Each of the examples returns the full contents of the file.
Some good stuff: