Remove try/catch
This commit is contained in:
@@ -11,6 +11,7 @@ const MessagePage = async () => {
|
|||||||
const sessionUser = await getSessionUser();
|
const sessionUser = await getSessionUser();
|
||||||
|
|
||||||
const { userId } = sessionUser;
|
const { userId } = sessionUser;
|
||||||
|
console.log(userId);
|
||||||
|
|
||||||
const readMessages = await Message.find({ recipient: userId, read: true })
|
const readMessages = await Message.find({ recipient: userId, read: true })
|
||||||
.sort({ createdAt: -1 }) // Sort read messages in asc order
|
.sort({ createdAt: -1 }) // Sort read messages in asc order
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { getServerSession } from 'next-auth/next';
|
|||||||
import { authOptions } from '@/utils/authOptions';
|
import { authOptions } from '@/utils/authOptions';
|
||||||
|
|
||||||
export const getSessionUser = async () => {
|
export const getSessionUser = async () => {
|
||||||
try {
|
|
||||||
const session = await getServerSession(authOptions);
|
const session = await getServerSession(authOptions);
|
||||||
|
|
||||||
if (!session || !session.user) {
|
if (!session || !session.user) {
|
||||||
@@ -13,8 +12,4 @@ export const getSessionUser = async () => {
|
|||||||
user: session.user,
|
user: session.user,
|
||||||
userId: session.user.id,
|
userId: session.user.id,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user