Skip to content

Instantly share code, notes, and snippets.

@mfaridzia
Created March 9, 2018 14:21
Show Gist options
  • Save mfaridzia/c4baf143087bf59c4fa6cd5e14ef55d6 to your computer and use it in GitHub Desktop.
Save mfaridzia/c4baf143087bf59c4fa6cd5e14ef55d6 to your computer and use it in GitHub Desktop.
<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