Skip to content

Instantly share code, notes, and snippets.

@mfaridzia
Created March 9, 2018 14:07
Show Gist options
  • Save mfaridzia/2e8b0f9dda439d52d65f39a1c3bd4ae7 to your computer and use it in GitHub Desktop.
Save mfaridzia/2e8b0f9dda439d52d65f39a1c3bd4ae7 to your computer and use it in GitHub Desktop.
<template>
<div id="container">
<header>
<h1> Daftar Nama User : </h1>
</header>
<div class="list">
<ul v-for="user in users" :key="user.id" style="list-style: none">
<li>
<router-link :to="{ name: 'User', params: { id: user.id } }">
{{ user.name }}
</router-link>
</li>
</ul>
</div>
</div>
</template>
<script>
import axios from 'axios'
export default {
data() {
return {
users: []
}
},
created() {
this.getAllUser()
},
methods: {
getAllUser() {
axios.get('https://jsonplaceholder.typicode.com/users')
.then((response) => {
this.users = response.data
console.log(response)
})
.catch((err) => {
console.log(err)
})
}
}
}
</script>
<style scoped>
.list {
margin-left: -50px;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment