I am using React and Next.js in my application. When a new user signs up, they go through the payment process and log in with Xero. However, after this step, the application redirects to the wrong condition because the user data isn’t inserted into MongoDB.
During debugging, I added a findOne
method to check if the email already exists before inserting the data. Despite using await
to handle the asynchronous process and passing only the email to check for existence, the data still isn’t being inserted into MongoDB. After the findOne
line, nothing happens—no console logs are printed. However, the odd part is that about 1 out of every 4–5 attempts succeeds in inserting the data.
The table and collection are being fetched correctly, so I’m not sure why this inconsistency is occurring. I urgently need help, as this issue is critical for my application.