Handling error exceptions, logger & using auth tokens
Unanswered
Beveren posted this in #help-forum
BeverenOP
I have a next.js 13.5.2 app using the app router setup.
It uses NextAuth to provide Azure AD users access to do updates to their calendar in Microsoft Graph API. I have 2 calls, a GET and a POST that need an API token to work.
When I use the POST call, how can I provide a set of custom error exception messages that I can view to a user (there can be many different ones on this one POST call)?
Also is there a logger middleware or something that I can use to see if my fetches done on server-side are working properly and also see what data they return?
When the POST call requires an API key and the page requires a 'use client'.
Do I need to add some route.ts files in /src/app directory that provide this API key for security? Or what are best practice here?
Then in the page where I do the POST after user filled out some form elements,
Do I use the async fetch functions added to /src/lib/getCalander & /src/lib/updateCalender that uses those API routes without the API token?
It uses NextAuth to provide Azure AD users access to do updates to their calendar in Microsoft Graph API. I have 2 calls, a GET and a POST that need an API token to work.
When I use the POST call, how can I provide a set of custom error exception messages that I can view to a user (there can be many different ones on this one POST call)?
Also is there a logger middleware or something that I can use to see if my fetches done on server-side are working properly and also see what data they return?
When the POST call requires an API key and the page requires a 'use client'.
Do I need to add some route.ts files in /src/app directory that provide this API key for security? Or what are best practice here?
Then in the page where I do the POST after user filled out some form elements,
Do I use the async fetch functions added to /src/lib/getCalander & /src/lib/updateCalender that uses those API routes without the API token?