account for rate limits, add dynamic url

This commit is contained in:
2024-07-09 20:16:00 -04:00
parent 018fc4ab8e
commit 944d27025f
3 changed files with 9 additions and 3 deletions
+1
View File
@@ -0,0 +1 @@
VITE_API_BASE_URL="http://localhost:3001/v4"
+1
View File
@@ -11,6 +11,7 @@ node_modules
dist
dist-ssr
*.local
.env
# Editor directories and files
.vscode/*
+6 -2
View File
@@ -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">