0

I am trying to get visualisations using github API data but cant seem to get it pulled. From the documentation I thought the following line would work but nothing prints to the console when I run it. Am I missing something

d3.json("https://api.github.com/search/users?q=ronanmacf", 
function(data) {
console.log(data[0]);
});

2 Answers 2

2

It works, but, in this case, the server response is an object, not an array so you get undefined with console.log(data[0]). If you change it like this console.log(data) you will see the github user data in the console. Run the code snippet below:

d3.json("https://api.github.com/search/users?q=ronanmacf", 
function(data) {
console.log(data);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.12.0/d3.min.js"></script>

0
0

In jQuery also we put console.log(data) instead of console.log(data[0])

$.getJSON( "https://api.github.com/search/users?q=ronanmacf", function( data ) {
  console.log(data);
 });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.