1

This is the api I am calling: https://api.github.com/search/repositories?q=language:python&sort=stars which return top starred python projects and displays when triggered via browser. But when I try to access the json keys from the code it says undefined. What am I doing wrong?

$.getJSON("https://api.github.com/search/repositories?q=language:python&sort=stars&callback=?", function(result){

  alert(typeof(result));
  alert(result.total_count);
  alert(result.incomplete_results);

});

1 Answer 1

1

Just remove the callback from url:

$.getJSON("https://api.github.com/search/repositories?q=language:python&sort=stars", function(result){

  alert(typeof(result));
  alert(result.total_count);
  alert(result.incomplete_results);

});

Here is a working fiddle: https://jsfiddle.net/a9npgduz/

Sign up to request clarification or add additional context in comments.

2 Comments

I wanted to know the jsonp implementation... The solution turned out to be result.data.key_name
The api documentantion has an example that can resolve your issue: developer.github.com/v3/#json-p-callbacks

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.