
We all are familiar with calling of HTTP based service in web development.So when it comes to HTTP request inside your Javascript we have multiple options like xmlhttp request or third party like axios and more recently we can use the fetch() method of new generation Javascript .Lets see how to implement fetch method in calling a webAPI.

To implement this fetch() we will be using API build in node.js https://apidemonodejs.herokuapp.com/skills
you can find the code base for the nodeAPI in my github repo https://github.com/VikasWilliam/Node-API
Lets see how to implement Fetch() method and get the JSON response from the API:
![74+] Johnny Bravo Wallpaper on WallpaperSafari](https://cdn.wallpapersafari.com/38/42/9AlzOp.jpg)
To use fetch we need to provide the API link as an argument:
fetch(“https://apidemonodejs.herokuapp.com/skills“)
fetch is basically a promise based method.Promise basically refers to an asynchronous computation which has not competed yet.For promise we use .then for access to the response and .json() to get it in json format as below:
.then((response)=>{ return response.json(); })
Further the promis can be resolved by using another .then method and the response can be logged in the browser console:
.then((data=>{ console.log(data); }))
the full code is as below:

This code needs to be pasted in the console to get the response on console of the browser.As below:


Note: Make sure CORS-Cross origin resource sharing is enabled in your browser. you can use “Allow CORS: Access-Control-Allow-Origin” plugin in your chrome browser.
THANKS. Have a great year ahead!!!!!!!
Like share and leave comment if you feel like 🙂
!!!!!!!!!!!!!!