Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let output = document.querySelector('#output');
- let userName = `WWWCourses`;
- let githubAPI = `https://api.github.com/users/${userName}/repos`;
- async function fetchAsync (url) {
- console.log(`Fetching from: ${url}`);
- // await response of fetch call
- let response = await fetch(url);
- // only proceed once promise is resolved
- let data = await response.json();
- console.log(`@@@@@`);
- console.dir(data);
- // only proceed once second promise is resolved
- return data;
- }
- let getReposNames = function(dataArr){
- console.dir(dataArr);
- dataArr.forEach( e => output.innerHTML += `<li>${e.name}</li>`)
- }
- // trigger async function
- fetchAsync(githubAPI)
- .then(dataArr => getReposNames(dataArr))
- .catch(reason => console.log(reason.message))
Add Comment
Please, Sign In to add comment