Created
March 9, 2018 14:21
-
-
Save mfaridzia/c4baf143087bf59c4fa6cd5e14ef55d6 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 class="container"> | |
<div class="user"> | |
<h2> Data user dengan nama : {{ user.name }} </h2> | |
<ul> | |
<li> Username : {{ user.username }} </li> | |
<li> Email : {{ user.email }} </li> | |
</ul> | |
<router-link to="/"> Back </router-link> | |
</div> | |
</div> | |
</template> | |
<script> | |
import axios from 'axios' | |
export default { | |
data() { | |
return { | |
user: [] | |
} | |
}, | |
created() { | |
this.getUser() | |
}, | |
methods: { | |
getUser() { | |
axios.get(`https://jsonplaceholder.typicode.com/users/${this.$route.params.id}`) | |
.then((response) => { | |
this.user = response.data | |
}) | |
.catch((err) => { | |
console.log(err) | |
}) | |
} | |
} | |
} | |
</script> | |
<style scoped> | |
ul li { | |
list-style: none; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment