From fb0685adf92bcd356d5b35d602c91c047a88d366 Mon Sep 17 00:00:00 2001 From: Christopher Arraya Date: Sun, 2 Jul 2023 20:51:59 -0400 Subject: [PATCH] update db --- lib/db.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/db.ts b/lib/db.ts index 091a3c7..95dff24 100644 --- a/lib/db.ts +++ b/lib/db.ts @@ -12,10 +12,15 @@ let client = : { conn: null, promise: null }; if (!client.promise) { - client.promise = MongoClient.connect(uri).then((mongoClient) => { - client.conn = mongoClient; - return mongoClient; - }); + client.promise = MongoClient.connect(uri) + .then((mongoClient) => { + client.conn = mongoClient; + return mongoClient; + }) + .catch((error) => { + console.error("Failed to connect to MongoDB", error); + throw error; + }); } export default client;