简体   繁体   中英

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

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM