INNER CODE UNIT · JavaScript
connectWithRetry
ivan3123708/fullstack-shopping-cart · backend/index.js:21
const connectWithRetry = () => {
console.log('CONNECTING TO DB...');
mongoose.connect(process.env.MONGODB_URI, {
auth: { authSource: 'admin' },
user: process.env.MONGODB_USER,
pass: process.env.MONGODB_PASSWORD,
}).then(() => {
console.log('CONNECTED TO DB!');
clearTimeout(connectWithRetry);
}).catch((err) => {
console.log(err);
connectionRetries++;
if (connectionRetries <= 4) {
setTimeout(connectWithRetry, 5000);
} else {