Skip to content

Commit

Permalink
AJAX-concepts are added
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayajahamad committed Oct 21, 2023
1 parent 7642906 commit 30a8574
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Javascript/08-AJAX/p4.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AJAX</title>
</head>
<body>
<center>
<h1>PROMISES</h1>
</center>
<hr>
<div id="git"></div>
<script>
fetch('assets/js/user.json')
.then(res => res.json())
.then(result => {
fetch(`https://api.github.com/users/${result.name}`)
.then(res => res.json())
.then(result =>{
console.log(result);

let img = document.createElement('img');
img.src = result.avatar_url;
let block = document.querySelector('#git')
block.appendChild(img)
})
})
.catch(error => {error})
</script>
</body>
</html>

0 comments on commit 30a8574

Please sign in to comment.