---
title: Web Fetch API
description: "> The Fetch API interface allows web browser to make HTTP requests to web servers. > > > > 😀 No need for XMLHttpRequest anymore. ## Browser Support The numbers in the table specify the first browser versions that fully support…"
url: "https://apprentice.mn/docs/web-fetch-api/"
updated: "2021-05-19"
category: Javascript
---

# Web Fetch API

> The Fetch API interface allows web browser to make HTTP requests to web servers.
>
>
>
> 😀 No need for XMLHttpRequest anymore.

## Browser Support

The numbers in the table specify the first browser versions that fully support Fetch API:

| Chrome | Internet explorer | Mozila firefox | Safari | Opera |
| --- | --- | --- | --- | --- |
| Chrome 42 | Edge 14 | Firefox 40 | Safari 10.1 | Opera 29 |
| Apr 2015 | Aug 2016 | Aug 2015 | Mar 2017 | Apr 2015 |

## A Fetch API Example

The example below fetches a file and displays the content:

### Example

              `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:

### Example

      `async function getText(file) {
  let x = await fetch(file);
  let y = await x.text();
  myDisplay(y);
}`

Or even bettter: Use understandable names instead of x and y:

### Example

      `async function getText(file) {
  let myObject = await fetch(file);
  let myText = await myObject.text();
  myDisplay(myText);
}`        [https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fapprentice.mn%2Fdocs%2Fweb-fetch-api%2F&linkname=Web%20Fetch%20API](https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fapprentice.mn%2Fdocs%2Fweb-fetch-api%2F&linkname=Web%20Fetch%20API)[https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Fapprentice.mn%2Fdocs%2Fweb-fetch-api%2F&linkname=Web%20Fetch%20API](https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Fapprentice.mn%2Fdocs%2Fweb-fetch-api%2F&linkname=Web%20Fetch%20API)[https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Fapprentice.mn%2Fdocs%2Fweb-fetch-api%2F&linkname=Web%20Fetch%20API](https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Fapprentice.mn%2Fdocs%2Fweb-fetch-api%2F&linkname=Web%20Fetch%20API)[https://www.addtoany.com/share](https://www.addtoany.com/share)
