From 7a7faf1e28aebbf5481c3a308dcaf1c76e271f5e Mon Sep 17 00:00:00 2001 From: Edwin Guzman Date: Tue, 19 Nov 2024 12:45:58 -0500 Subject: [PATCH] adding logs to help debug --- package-lock.json | 4 ++-- pages/_app.tsx | 1 + pages/api/submit.ts | 4 +++- src/components/ApiErrors/index.tsx | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6bb1b4f5..0c0ba0d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "nypl-library-card-app", - "version": "1.0.0", + "version": "2.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "nypl-library-card-app", - "version": "1.0.0", + "version": "2.0.0", "license": "MIT", "dependencies": { "@babel/preset-typescript": "7.10.4", diff --git a/pages/_app.tsx b/pages/_app.tsx index 98de1545..c98ef7f6 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -92,6 +92,7 @@ function MyApp({ Component, pageProps }: MyAppProps) { errorObject ); } + console.log("MyApp error: ", error); // We don't want to keep the errors in this object since it's // going to go into the app's store. delete router.query.errors; diff --git a/pages/api/submit.ts b/pages/api/submit.ts index 83f78f70..a0f34d3a 100644 --- a/pages/api/submit.ts +++ b/pages/api/submit.ts @@ -31,7 +31,8 @@ async function serverSubmit(req: NextApiRequest, res: NextApiResponse) { let newSubmittedValues = { ...req.body }; // All already submitted values are stored here so we dont run validations // on those values again. - const existingValues = JSON.parse(req.body.formValues); + console.log("serverSubmit - req.body.formValues: ", req.body.formValues); + const existingValues = !req.body.formValues ? {} : JSON.parse(req.body.formValues); const currentPage = req.body.page; // We don't want these values when we do validation. delete newSubmittedValues.page; @@ -101,6 +102,7 @@ async function serverSubmit(req: NextApiRequest, res: NextApiResponse) { results = await callPatronAPI(existingValues); page = "congrats"; } catch (error) { + console.log("Error in serverSubmit", error); errors = error; } break; diff --git a/src/components/ApiErrors/index.tsx b/src/components/ApiErrors/index.tsx index 73e6aee9..99bfbe70 100644 --- a/src/components/ApiErrors/index.tsx +++ b/src/components/ApiErrors/index.tsx @@ -32,6 +32,7 @@ const ApiErrors = React.forwardRef( } if (typeof problemDetail !== "string" && !problemDetail.detail) { + console.log("ApiErrors problemDetail: ", problemDetail); problemDetail.detail = t("apiErrors.defaultError"); } if (lang !== "en" && typeof problemDetail !== "string") {