John Philip

Fetch function and how to use the fetch API

“The Fetch API provides a JavaScript interface for accessing and manipulating parts of the HTTP pipeline, such as requests and responses. It also provides a global fetch() a method that provides an easy, logical way to fetch resources asynchronously across the network” from

In order to understand fetch() first, we need to understand what is an API (Application Programming Interface)

API is “An application programming interface is a computing interface which defines interactions between multiple software intermediaries. It defines the kinds of calls or requests that can be made, how to make them, the data formats that should be used, the conventions to follow” from Wikipedia.

Fetch allows us to make API calls to get information and use the returned data.

It is a browser-based function and uses the GET, POST, and DEL methods.

The fetch () method take into two parameters either the URL or the file name

The Fetch function always returns a promise.

A fetch response has a body that can be accessed either through.JSON, .TEXT. FORMDATA e.t.c. JSON is the most common and it is a format in which data is stored into javascript inform of arrays and objects.

Fetch () is very handy when dealing with APIs and JSON data.

We will see how the fetch () works in the example below

Example of a fetch request.


Fetch function is very handy when dealing with API’’s and you should give it a try if you haven't yet.

Web developer, Life Café , Curious Soul, twitter at @amjohnphilip,

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store