Advertisement
ph4x35ccb

api GIThub

Nov 5th, 2019
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Nao consegui parcear os dados do jeito que eu quero mas a intenção e passa a pesquisa por uma variável com o conteúdo do post ou getr de um formulario e concatenar na requisiçao
  2.  
  3. <!DOCTYPE html>
  4. <html lang="pt-br">
  5. <head>
  6.     <meta charset="utf-8">
  7.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  8.     <title>GitHub - Repositorios</title>
  9.     <link rel="stylesheet" href="gitStyle.css">
  10. </head>
  11. <body>
  12.     <header>
  13.         <div class="banner">
  14.             banner
  15.         </div>
  16.     </header>
  17.     <main>
  18.         <section id="content">
  19.             <div class="git-content">
  20.                
  21.             </div>
  22.         </section>
  23.     </main>
  24.     <script src="jsGit.js"></script>
  25. </body>
  26. </html>
  27.  
  28. =============
  29. salve em um arquivo jsGit.js
  30. var myReq = new XMLHttpRequest();
  31. myReq.onload = function(){
  32.     console.log(JSON.parse(this.response));
  33.     var conteudo = this.response;
  34.     document.querySelector('.git-content').innerHTML=conteudo;
  35. }
  36. myReq.open('get','https://api.github.com/search/repositories?q=PHP', true);
  37. myReq.send();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement