Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>github user finder using github api</title>


<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<body>
<div class="container">
<br><br>

<h1 style="text-align: center;">
Github search user app

</h1>
<form id="myform" autocomplete="off">
<div class="form-group">
<input type="text" class="form-control" id="search" placeholder="search username" required>
</div>
<div class="form-group">

<button class="btn btn-danger btn-block">
search user
</button>
</div>
</form>
<div id="result"></div>
</div>
</body>
<script src="script.js"></script>

</html>
25 changes: 25 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var form = document.getElementById("myform")


form.addEventListener('submit',function(e){
e.preventDefault()

var search = document.getElementById("search").value



var originalName = search.split(' ').join('')

document.getElementById("result").innerHTML = ""

fetch("https://api.github.com/users/"+originalName)
.then((result) => result.json())
.then((data) => {


console.log(data)
document.getElementById("result").innerHTML =`
<a target= "blank" href="https://www.github.com/${originalName}"> <img src="${data.avatar_url}"/></a>
`
})
})