XHR or XML HTTP request is an object utilising the AJAX technique to communicate with the server. 
However, XHR is not used in the industry nowadays because it uses callbacks. Can you guess what problems the developer might run into while using XHR?

  • Any application using callbacks has the possibility of running into callback hell. We learnt about callback hell in much greater detail in the advanced JavaScript module. We also learnt that it is possible to avoid a callback hell by using promises and/or async-await instead of callbacks.
  • Fetch is a new native JavaScript API supported by most browsers today. Fetch allows you to make network requests similar to XMLHttpRequest. It communicates with the server which uses promises instead of callbacks.

Although Fetch primarily uses promises, it can also use async-await. In the project, the SME will use Fetch in conjunction with async-await.

We can understand the main features of Fetch from the following image: