Skip to content

Instantly share code, notes, and snippets.

@donvito
Created November 10, 2018 06:46
Show Gist options
  • Save donvito/21e37bb931ea9e7e70b10aba21653974 to your computer and use it in GitHub Desktop.
Save donvito/21e37bb931ea9e7e70b10aba21653974 to your computer and use it in GitHub Desktop.
Vue.js code to query github API
<html>
<head>
<script src="https://unpkg.com/vue"></script>
</head>
<body>
<div id="app">
<github-repo-list
v-for="repo in repos"
v-bind:repo="repo"
v-bind:key="repo.name"
v-bind:key="repo.id">
</github-repo-list>
</div>
</body>
</html>
<script>
new Vue({
el: '#app',
data: {
repos : [],
},
created(){
fetch("https://api.github.com/users/donvito/repos")
.then(response => response.json())
.then((data) => {
this.repos = data;
console.log(data)
})
}
});
Vue.component('github-repo-list', {
props: ['repo'],
template: '<li>{{ repo.id }} / {{ repo.name }}</li>'
})
</script>
@donvito
Copy link
Author

donvito commented Nov 10, 2018

Just open in the browser to test, no need to run in a web server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment