Browser Fetch API

Fetch is browser API ,it is used to make AJAX call to server without disturbing full page of application, it resides in window object of the browser.

Fetch API send a AJAX request with corresponding input request[User provided ] to server then server response to that request.

headers: {
‘Accept’: ‘application/json’,
‘Content-Type’: ‘application/json’
method: “GET”
.then(response => response.json())
.then(json => console.log(json)).catch(err=>console.log(err))

Headers :- provide header information like content-type, Auth -token etc..
Method :- Type of http request like GET , POST ,PUT , DELETE, PATCH etc…
Then and catch :- Both are callbacks, Then executes once request resolves successfully, it may contains multiple then block first then block response is passed to another then block