2016-01-30 78 views

回答

0

都能跟得上。你可以使用簡單的JavaScript,或者你可以照原樣捲曲它。

捲曲它在終端上:

$ curl https://api.github.com/users/Evin1-/repos 

或...一個JavaScript函數與API進行通信(如前面的捲曲功能相同的數據):

<html> 
<head> 
<script> 
    var request = new XMLHttpRequest(); 
    request.open("GET", 'https://api.github.com/users/Evin1-/repos'); 
    request.onreadystatechange = function() { 
     if (request.readyState === 4 && request.status === 200) { 
      console.log(request); 
      var p_placeholder = document.getElementById("result_placeholder"); 
      p_placeholder.innerHTML = request.response; 
     } 
    }; 
    request.send(null); 
</script> 
</head> 
<body> 
    <p id="result_placeholder"></p> 
</body> 
</html> 
相關問題