-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathindex.vue
79 lines (66 loc) · 1.51 KB
/
index.vue
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<template>
<section class="index-page">
<h2>#</h2>
<form @submit.prevent="onSubmit">
<input
autocomplete="true"
placeholder="Email"
type="email"
v-model="email"
>
<input
autocomplete="current-password"
placeholder="Password"
type="password"
v-model="password"
>
<recaptcha
@error="onError"
@success="onSuccess"
@expired="onExpired"
@load="onLoad"
/>
<button type="submit">#</button>
<nuxt-link :to="{ name: 'about' }">About</nuxt-link>
</form>
</section>
</template>
<script>
export default {
data: () => ({
email: 'test@example.com',
password: '123',
}),
methods: {
onError (error) {
console.log('Error happened:', error)
},
async onSubmit() {
try {
const token = await this.$recaptcha.getResponse()
const response = await fetch('/api/check-token', {
method: 'POST',
body: JSON.stringify({
token,
email: this.email,
password: this.password
})
}).then(res => res.json())
console.log('Server Response: ', response)
await this.$recaptcha.reset()
} catch (error) {
console.log('Login error:', error)
}
},
onSuccess (token) {
console.log('Succeeded:', token)
},
onExpired () {
console.log('Expired')
},
onLoad () {
console.log('Loaded')
}
},
}
</script>