As a developer, We all come across making HTTP request either in web or in mobile app development. After becoming javascript frontend frameworks so popular, Every developer comes across these methods.
Nowadays, There are various ways to make an HTTP request in the client application. In this article, I will explain the popular ways of fetching data from the server after making HTTP request.
The fetch API provides a fetch() method which we can use to perform an HTTP request. It returns a Promise that we can use to retrieve the response data from the request made. It takes only one mandatory argument, Which is the endpoint URL of the resource we want to fetch.
It is a Promise based HTTP client. It is a big advantage of using Promises when dealing with code that required a more complicated chain of events.
The HttpClient
in @angular/common/http
offers a simplified client HTTP API for Angular applications that rests on the XMLHttpRequest
interface exposed by browsers. Additional benefits of HttpClient
include testability features, typed request and response objects, request and response interception, Observable
apis, and streamlined error handling.
AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page. In AJAX, we mainly initialize a new XMLHttpRequest() method, specifing the URL endpoint and HTTP method. For getting detailed info, you can click here
jQuery has various methods to make HTTP requests. For using this method we need to include jQuery library in our project.
That’s all for now. Thank you for reading and I hope this post will be very helpful for understanding the popular ways to make an HTTP request.
Let me know your thoughts over the email demo.jsonworld@gmail.com. I would love to hear them and If you like this article, share with your friends.