2016-11-07 20:38:51 +00:00
|
|
|
<template>
|
|
|
|
<div class="user">
|
|
|
|
<h3>{{ name }}</h3>
|
2016-11-07 20:58:56 +00:00
|
|
|
<h4>@{{ username }}</h4>
|
2016-11-07 20:38:51 +00:00
|
|
|
<p>Email : {{ email }}</p>
|
2016-11-07 20:58:56 +00:00
|
|
|
<p><router-link to="/">List of users</router-link></p>
|
2016-11-07 20:38:51 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import axios from 'axios'
|
|
|
|
|
|
|
|
export default {
|
2016-11-17 10:57:02 +00:00
|
|
|
data ({ params, error }) {
|
2016-11-07 20:38:51 +00:00
|
|
|
return axios.get(`http://jsonplaceholder.typicode.com/users/${params.id}`)
|
|
|
|
.then((res) => res.data)
|
2016-11-17 10:57:02 +00:00
|
|
|
.catch(() => {
|
|
|
|
error({ message: 'User not found', statusCode: 404 })
|
|
|
|
})
|
2016-11-07 20:38:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2016-11-07 20:58:56 +00:00
|
|
|
<style scoped>
|
|
|
|
.user {
|
|
|
|
text-align: center;
|
|
|
|
margin-top: 100px;
|
|
|
|
font-family: sans-serif;
|
|
|
|
}
|
2016-11-07 20:38:51 +00:00
|
|
|
</style>
|