UNPKG

realworld-api

Version:

RealWorld library for open API calls using JavaScript

32 lines (30 loc) 1.09 kB
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> </head> <body> <h1>Articles</h1> <div id='list'></div> <script src="https://unpkg.com/realworld-api/realworld.min.js"></script> <script> var client = new RealWorld() client.listAllArticles(function (err, res, body) { if (err) console.error(err) else { var parent = document.getElementById('list') body.articles.forEach(function (article) { var el = document.createElement('div') var title = document.createElement('h2') title.innerText = article.title el.appendChild(title) var description = document.createElement('p') description.innerText = article.description el.appendChild(description) parent.appendChild(el) }) } }) </script> </body> </html>