I've used this piece of code to GET data from the GitHub API
var name;
var description;
var html_url;
var username = "PirateStef";
var updated_at;
var language;
var repo;
var urlGitHub = 'https://api.github.com/users/'+username+'/repos?sort=created';
$.getJSON(urlGitHub, function(json){
repositories = json;
outputGitHubContent(); // GitHub Content
});
function outputGitHubContent() {
$.each(repositories, function(index){
name = "<div class='name'>" + repositories[index].name + "</div>";
description = "<div class='description'>" + repositories[index].description + "</div>";
updated_at = "<div class='updated_at'>" + repositories[index].updated_at.substring(0,10) + "</div>";
html_url = "<a class='html_url' target='_blank' href='" + repositories[index].html_url + "'>";
language = "<div class='language'>" + repositories[index].language + "</div>";
repo = "<div class='repo'>" + html_url + "<div>" + name + language + "</div>" + description + updated_at + "</a> </div>";
console.log(repositories[index].owner.login);
$("#github").append(repo);
});
};
This is the Github API url
https://api.github.com/users/PirateStef/repos?sort=updated
I've tried to build a function to GET the dribbble data. Using the api.dribbble url below.
http://api.dribbble.com/players/PirateStef/shots/
I'm having trouble getting the "title" from each object.
The dribbble code that isn't working
var urlDribbble = 'http://api.dribbble.com/players/'+username+'/shots/';
var shot;
$.getJSON(urlDribbble, function(json){
shots = json;
outputDribbbleContent(); // Dribbble Content
});
function outputDribbbleContent() {
$.each(shots, function(index){
console.log(shots[index].title);
});
};
gets me 5x undefined
console.log(shots[index]);
gets me this
[
Object
,
Object
,
Object
,
Object
,
Object
,
Object
,
Object
,
Object
,
Object
,
Object
,
Object
,
Object
,
Object
]