Sfoglia il codice sorgente

Catch mongo errors

Tati 7 anni fa
parent
commit
06d98d84ba
1 ha cambiato i file con 1 aggiunte e 1 eliminazioni
  1. 1 1
      ktchn/src/recipes/controller.ts

+ 1 - 1
ktchn/src/recipes/controller.ts

@@ -11,7 +11,7 @@ const saveRecipe = (db: IMongoService) => ({ body }: Request, res: Response, nex
     db.insertOne(body).then(DBRecipe => {
       res.json(DBRecipe);
       next();
-    })
+    }).catch(error => { next(error) })
   } else {
     next(new Error('Missing recipe information'));
   }