#Email already exists in database

12 messages · Page 1 of 1 (latest)

prisma shard
#

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??

leaden coral
plain rivet
#

i think your browser reloaded during the time of inserting this user detail

prisma shard
prisma shard
leaden coral
prisma shard
# leaden coral Can you log all the parameters you're passing to the function? Along with the ID...

@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

prisma shard
# leaden coral Can you log all the parameters you're passing to the function? Along with the ID...

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
leaden coral
leaden coral
prisma shard
leaden coral
#
print(client.config)
print(userdeets.email)