Created
March 9, 2018 14:07
-
-
Save mfaridzia/2e8b0f9dda439d52d65f39a1c3bd4ae7 to your computer and use it in GitHub Desktop.
This file contains 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> | |
<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