Files
2025-01-09 10:54:23 -03:00

25 lines
712 B
JavaScript

const app = Vue.createApp({
data() {
return {
firstName: 'John',
lastName: 'Doe',
email: 'john@gmail.com',
gender: 'male',
picture: 'https://randomuser.me/api/portraits/men/10.jpg',
};
},
methods: {
async getUser() {
const res = await fetch('https://randomuser.me/api/');
const { results } = await res.json();
this.firstName = results[0].name.first;
this.lastName = results[0].name.last;
this.email = results.email;
this.gender = results[0].gender;
this.picture = results[0].picture.large;
},
},
});
app.mount('#app');