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