HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
The Fetch API interface allows web browser to make HTTP requests to web servers
The numbers in the table specify the first browser versions that fully support Fetch API:
Chrome 42 | Edge 14 | Firefox 40 | Safari 10.1 | Opera 29 |
Apr 2015 | Aug 2016 | Aug 2015 | Mar 2017 | Apr 2015 |
The example below fetches a file and displays the content:
fetch(file)
.then(x => x.text())
.then(y => myDisplay(y));
Since Fetch is based on async and await, the example above might be easier to understand like this:
async function getText(file) {
let x = await fetch(file);
let y = await x.text();
myDisplay(y);
}
Or even better: Use understandable names instead of x and y:
async function getText(file) {
let myObject = await fetch(file);
let myText = await myObject.text();
myDisplay(myText);
}