I deployed a website with a waiting list, it sends the user email and name to the appwrite DB. It works well locally but when i deployed the website, anyone that signs up gets an error; 'Document with the requested ID already exists. Try again with a different ID or use ID.unique() to generate a unique ID.' This is as simple as it gets. Just a form with 3 fields sending data straight to a DB (unqiue index on email). I think this is an issue with appwrite, why would this work locally and not in production??
#Email already exists in database
12 messages · Page 1 of 1 (latest)
The problem is probably due to a duplicate email
i think your browser reloaded during the time of inserting this user detail
I know, i created the unique index. The database doesn't have any such email. The DB is empty but i'm getting a duplicate email response?
the details aren't added onto the DB.
Can you log all the parameters you're passing to the function? Along with the IDs for your project, database and collection? And share them?
@app.post("/api/waitinglist", status_code=status.HTTP_200_OK)
async def waitlist( userdeets: WaitlistRequest):
try:
database = Databases(client).create_document(database_id= '673e42b5001238e49296', collection_id= '678ecd3a00249d052910', document_id= ID.unique(),
data={'email' : userdeets.email , 'age' : int(userdeets.age) , 'Country': userdeets.country } )
return { f'succesfully added user to waiting list'}
except Exception as e:
print(e)
raise HTTPException(status_code= status.HTTP_400_BAD_REQUEST , detail= str(e)) # Return an appropriate error status code
this is the endpoint
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { name, value } = e.target;
setFormData(prev => ({ ...prev, [name]: value }));
};
const handleCountryChange = (value: Country) => {
setFormData(prev => ({ ...prev, country: value }));
};
const handleSubmit = async (e: React.FormEvent) => {
try {e.preventDefault();
setIsSubmitting(true)
// Simulate sending data to a database
await axios.post('/api/waitinglist', {'email' : formData.email, 'age' : formData.age, 'country' : formData.country})
this is the front end
FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting).
You're not logging and sharing the exact values so I can't validate them
i don't know how to log- i'll look into it and redeploy. i have another issue with the oauth2 google- it redirects to a url with the secret as a parameetr in the url. This is a major security vulnerability- this can't be correct. I can't work aorundit because the the ouath2 func returns a google link which sends the said url.
print(client.config)
print(userdeets.email)