2016-11-07 20:38:51 +00:00
|
|
|
<template>
|
2016-12-11 15:40:18 +00:00
|
|
|
<div class="container">
|
|
|
|
<h2>User</h2>
|
2016-11-07 20:38:51 +00:00
|
|
|
<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-12-11 15:40:18 +00:00
|
|
|
<p><router-link to="/users">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-27 18:26:42 +00:00
|
|
|
return axios.get(`https://jsonplaceholder.typicode.com/users/${params.id}`)
|
2016-11-07 20:38:51 +00:00
|
|
|
.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>
|
2016-12-11 15:40:18 +00:00
|
|
|
.container
|
|
|
|
{
|
|
|
|
text-align: center;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
/*.user {
|
2016-11-07 20:58:56 +00:00
|
|
|
text-align: center;
|
|
|
|
margin-top: 100px;
|
|
|
|
font-family: sans-serif;
|
2016-12-11 15:40:18 +00:00
|
|
|
}*/
|
2016-11-07 20:38:51 +00:00
|
|
|
</style>
|