Skip to content

Instantly share code, notes, and snippets.

@spemer
Last active October 14, 2021 05:02
Show Gist options
  • Save spemer/296d81842856f5df236486b093f25ac7 to your computer and use it in GitHub Desktop.
Save spemer/296d81842856f5df236486b093f25ac7 to your computer and use it in GitHub Desktop.
App.vue -> axios
<template lang="pug">
div#app
div(
v-for="user in users"
:key="users.id"
)
h1 {{ user.name }}
p {{ user.email }}
button(@click="fetchUsers") Click me!
</template>
<script>
export default {
name: 'app',
data () {
return {
users: []
}
},
methods: {
fetchUsers: function () {
const baseURI = 'https://jsonplaceholder.typicode.com/users'
this.$http.get(baseURI)
.then((result) => {
this.users = result.data
})
}
}
}
</script>
<style lang="scss">
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: left;
width: 640px;
margin: 0 auto;
color: #2c3e50;
margin-top: 60px;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment