Skip to content

Instantly share code, notes, and snippets.

@donvito
Created May 27, 2018 15:56
Show Gist options
  • Save donvito/88e69ce0b3872ac5a0b93d3cb4937b12 to your computer and use it in GitHub Desktop.
Save donvito/88e69ce0b3872ac5a0b93d3cb4937b12 to your computer and use it in GitHub Desktop.
Query GitHub API repos using Vue.js
<script src="https://unpkg.com/vue"></script>
<div id="githubRepos">
</div>
<script>
new Vue({
el: '#githubRepos',
data: {
repos : [],
},
mounted(){
fetch("https://api.github.com/users/donvito/repos")
.then(response => response.json())
.then((data) => {
this.repos = data;
})
},
template: `
<div>
<li v-for="repo in repos">
{{ repo.name }}
</li>
</div>
`
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment