passes some input to the fetch api.
Sat Oct 24 2020 17:50:52 GMT+0000 (Coordinated Universal Time)
Saved by
@jlang
var getUserRepos = function (user) {
var apiUrl = 'https://api.github.com/users/' + user + '/repos';
fetch(apiUrl)
.then(function (response) {
if (response.ok) {
console.log(response);
response.json().then(function (data) {
console.log(data);
//calls display repos function
displayRepos(data, user);
});
} else {
alert('Error: ' + response.statusText);
}
})
.catch(function (error) {
alert('Unable to connect to GitHub');
});
};
content_copyCOPY
Comments