Fetch function and how to use the fetch API
fetch() a method that provides an easy, logical way to fetch resources asynchronously across the network” from Mozilla.org
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.
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.