-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (30 loc) · 1.05 KB
/
index.js
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
const proxyurl = 'https://cors-anywhere.herokuapp.com/'
const url =
'https://cors-anywhere.herokuapp.com/https://us-central1-otp-react-native-4e01f.cloudfunctions.net/Mailer'
const submitbtn = document.querySelector('.submit-btn')
submitbtn.addEventListener('click', async event => {
event.preventDefault()
const fullname = document.querySelector('.fullname').value
const email = document.querySelector('.email').value
const message = document.getElementById('message').value
if (!fullname || !email || !message) {
return alert('fields cannot be empty')
}
submitbtn.textContent = 'Sending mail...'
try {
const mail = await axios.post(url, {
subject: fullname,
from: email,
message
})
submitbtn.textContent = 'Mail Sent'
document.querySelector('.fullname').value = ''
document.querySelector('.email').value = ''
document.getElementById('message').value = ''
submitbtn.disabled = true
console.log(mail)
} catch (err) {
console.log(err)
submitbtn.textContent = 'Failed to send the mail'
}
})