javascript - Parsing GitHub API response -


i want list of repositories github account , url using https://api.github.com/users/rakeshdas1/repos. want parse using jquery , output html page. code using achieve is:

$(document).ready(function(){     var json = "https://api.github.com/users/rakeshdas1/repos";     $.each(json.parse(json), function(idx, obj) {         $("#repos").append("<p>"+obj.name+"</p>");     }); }); 

syntaxerror: json.parse: unexpected character @ line 1 column 1 of json data

the first character in json file '[' , don't know why jquery can't parse it

as rory said in comments, no ajax request being made. trying parse string "https://api.github.com/users/rakeshdas1/repos" json.

what may looking call $.get download result of api call, parse inside function.

the following code fails me due network restrictions, should give right idea. might work you.

$(document).ready(function () {     var api = "https://api.github.com/users/rakeshdas1/repos";     $.get(api, function (data) {         $.each(data, function (idx, obj) {             $("#repos").append("<p>" + obj.name + "</p>");         });     }); }); 

Popular posts from this blog