account for rate limits, add dynamic url
This commit is contained in:
@@ -0,0 +1 @@
|
||||
VITE_API_BASE_URL="http://localhost:3001/v4"
|
||||
@@ -11,6 +11,7 @@ node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
.env
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
|
||||
@@ -22,7 +22,7 @@ export default function ContactForm() {
|
||||
} else {
|
||||
console.log("Form submitted")
|
||||
|
||||
fetch("https://api.alexav.gg/v4/contact", {
|
||||
fetch(import.meta.env.VITE_API_BASE_URL + "/contact", {
|
||||
method: "post",
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
@@ -31,9 +31,13 @@ export default function ContactForm() {
|
||||
}).then((res) => {
|
||||
if (res.ok) {
|
||||
setSuccess(true)
|
||||
} else {
|
||||
if (res.status === 429) {
|
||||
setError("Too many tries! Try again later")
|
||||
} else {
|
||||
setError("An error occurred while submitting your info.")
|
||||
}
|
||||
}
|
||||
}).catch((e) => {
|
||||
console.error(e)
|
||||
setError("An error occurred while submitting your info.")
|
||||
@@ -50,7 +54,7 @@ export default function ContactForm() {
|
||||
setTimeout(() => {
|
||||
setSuccess(false)
|
||||
}, 6000)
|
||||
})
|
||||
}, [success]);
|
||||
|
||||
return (
|
||||
<div className="bg-white rounded-lg text-black p-2">
|
||||
|
||||
Reference in New Issue
Block a user