mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-07 09:22:27 +00:00
38 lines
741 B
Vue
38 lines
741 B
Vue
<template>
|
|
<div class="container">
|
|
<h2>User</h2>
|
|
<h3>{{ user.name }}</h3>
|
|
<h4>@{{ user.username }}</h4>
|
|
<p>Email : {{ user.email }}</p>
|
|
<p><router-link to="/users">List of users</router-link></p>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import axios from 'axios'
|
|
|
|
export default {
|
|
data ({ params, error }) {
|
|
return axios.get(`https://jsonplaceholder.typicode.com/users/${params.id}`)
|
|
.then((res) => { return { user: res.data } })
|
|
.catch(() => {
|
|
error({ message: 'User not found', statusCode: 404 })
|
|
})
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.container
|
|
{
|
|
text-align: center;
|
|
overflow: hidden;
|
|
min-height: 440px;
|
|
}
|
|
/*.user {
|
|
text-align: center;
|
|
margin-top: 100px;
|
|
font-family: sans-serif;
|
|
}*/
|
|
</style>
|