Home > Blockchain >  Using JavaScript or html to pull live data(cryptocurrency statistics from another site)
Using JavaScript or html to pull live data(cryptocurrency statistics from another site)

Time:12-31

I'm a beginner to coding and I'm creating a site on educating teens on cryptocurrency where I would like to have a page consisting of live data of different currencies using only javascript and html(css if needed to). Seen a lot on fetch api, etc, but really not sure on how to do it.

CodePudding user response:

You want to look for Jquery library for JS, HTML and CSS will not be enough to do api calls, JS will do that for you,

Having timer set to x amount to call the api and feed the html with data.

CodePudding user response:

In JavaScript, to fetch data from a website, you can use the Fetch API.

This is an example that fetches data from this GitHub page.

fetch('https://api.github.com/zen')
.then(resp => resp.text())
.then(text => console.log(text));

If the response is in JSON, you can use resp.json() instead of resp.text() to parse it into a JavaScript object.

  • Related