diff --git a/index.js b/index.js new file mode 100644 index 0000000..090ac5e --- /dev/null +++ b/index.js @@ -0,0 +1,28 @@ +//fetch data from form! +var form = document.getElementById("myForm"); + + +form.addEventListener('submit', function (e) { + + //prevent the auto submission of form + e.preventDefault(); + + var search = document.getElementById("search").value; + + //to remove space in b/w firstName & lastName + 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").classList.add("discription"); + + document.getElementById("result").innerHTML = ` + + ` + }) +}) \ No newline at end of file diff --git a/searchbar.html b/searchbar.html new file mode 100644 index 0000000..a4e5144 --- /dev/null +++ b/searchbar.html @@ -0,0 +1,39 @@ + + + +
+ + +