Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Load Repos</title>
- <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
- </head>
- <body>
- <div id="text">
- GitHub username:
- <input type="text" id="username"/>
- <button onclick="loadRepos">Load Repos</button>
- </div>
- <ul id="results"></ul>
- <script>
- function loadRepos() {
- let username = $('#username').val();
- $.get("https://api.github.com/users/" + username + "/repos")
- .then(function (data) {
- $("#results").append($("<li>").text(data));
- })
- .catch(function () {
- $("#results").append($("<li>Error</li>"));
- });
- }
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment