I'm trying to connect React website to MongoDB, When I submit the username, email and password this message appears to me. although the first attempt success.
Error Message
xhr.js:187 POST http://localhost:8080/register 500 (Internal Server Error)
createError.js:16 Uncaught (in promise) Error: Request failed with status code 500
db.js
const dotenv = require("dotenv")
dotenv.config()
const mongodb = require("mongodb")
mongodb.connect(process.env.CONNECTIONSTRING, { useNewUrlParser: true, useUnifiedTopology: true }, function(err, client) {
if (err) {
console.log(err)
}
module.exports = client
const app = require("./app")
app.listen(process.env.PORT)
})
.env
CONNECTIONSTRING=mongodb+srv://username
PORT=8080
JWTSECRET=password
Can anyone help me with this, thank you In advance!