Last active
October 14, 2021 05:02
-
-
Save spemer/296d81842856f5df236486b093f25ac7 to your computer and use it in GitHub Desktop.
App.vue -> axios
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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