-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (29 loc) · 797 Bytes
/
Copy pathapp.js
File metadata and controls
31 lines (29 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const app = Vue.createApp({
data() {
return {
firstName: null,
lastName: null,
email: null,
gender: null,
picture: null,
isUserReady: false
}
},
methods: {
async getUser() {
const res = await fetch('https://randomuser.me/api')
const { results } = await res.json()
console.log(results);
this.firstName = results[0].name.first
this.lastName = results[0].name.last
this.email = results[0].email
this.gender = results[0].gender
this.picture = results[0].picture.large
}
},
async created() {
await this.getUser()
this.isUserReady = true
},
})
app.mount('#app')