Hey guys,
Fetching data from api involves 2 steps:
1.Add jquery CDN script to support jquery function
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
2.Use $.getJSON() function to fetch data.
<script>
$.getJSON("API URL",function(response)
{
console.log(response);
}
);
</script>
Explanation:
In the above function, first parameter is the api url which you want to fetch data and second parameter is function to get the response of that api. The parameter passed to that function has the output stored in that variable on success. Then you can play around with that data.
In this way, we fetch the api data using javascript.
Hope this finds helpful, Please do comment, if you have any doubts or facing problems in javascript or html, css, php, mysql, will do a post on it.
Thanks!
Wow..its great to know but it will be very effective if can increase the size of the pics where you put those commands
ReplyDeleteThanks for the response.As you said,I will keep the commands effectively.
DeleteVery good information. Keep on posting like this.
ReplyDeleteThanks!
Delete