Fetch API is a promise-based easy to use alternative for XMLHttpRequest. Let’s look at how the Fetch API helps you work with RESTful Interfaces.

If you are writing a web application, chances are you will have to work with external data. This can be your own database, third party APIs, and so on.

When AJAX first appeared in 1999, it showed us a better way to build web applications. AJAX was a milestone in web development and is the core concept behind many modern technologies like React.

Before AJAX, you had to re-render an entire web page even for minor updates. But AJAX gave us a way to fetch content from the backend and update selected user interface elements. This helped developers improve user experience and build larger, complicated web platforms.

Crash Course on REST APIs

We are now in the age of RESTful APIs. Simply put, a REST API lets you push and pull data from a datastore. This might either be your database or a third party’s server like the Twitter API.

There are a few different types of REST APIs. Let’s look at the ones you will use in most cases.

  • GET — Get data from the API. For example, get a twitter user based on their username.
  • POST — Push data to the API. For example, create a new user record with name, age, and email address.
  • PUT — Update an existing record with new data. For example, update a user’s email address.
  • DELETE — Remove a record. For example, delete a user from the database.

#javascript #web-development #developer

JavaScript Fetch API Tutorial with JS Fetch Post and Header Examples
2.50 GEEK