-
-
Save uno-de-piera/bbf5872d95e405ab14fe76564e3d6979 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> | |
<h2>Listado de usuarios</h2> | |
<ul v-if="users.length"> | |
<li v-for="user in users" :key="user.id"> | |
{{ user.name }} - {{ user.email }} | |
</li> | |
</ul> | |
<p v-else>No hay usuarios disponibles</p> | |
</div> | |
</template> | |
<script> | |
export default { | |
name: "UsersList", | |
async mounted() { | |
const response = await fetch("https://jsonplaceholder.typicode.com/users"); | |
this.users = await response.json(); | |
}, | |
data() { | |
return { | |
users: [] | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment