Skip to content

Instantly share code, notes, and snippets.

@whichbuffer
Last active November 16, 2020 18:55
Show Gist options
  • Save whichbuffer/1caa5093f11f99698b569b5401bd58f3 to your computer and use it in GitHub Desktop.
Save whichbuffer/1caa5093f11f99698b569b5401bd58f3 to your computer and use it in GitHub Desktop.
async function getJson(){
const response = await fetch('https://randomuser.me/api/?results=10');
const data = await response.json();
console.log(data.results);
for(let i=0;i<data.results.length;i++){
document.getElementById('authors').innerHTML
+=("<br>" + data.results[i].name.first + " " + data.results[i].name.last + "<br>");
}
}
getJson().catch(error => {
console.log("error!");
console.error(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment