frontend/src/routes/api/get-notifications/+server.ts
2024-11-05 18:30:35 +01:00

21 lines
462 B
TypeScript

import type { RequestHandler } from "./$types";
export const GET: RequestHandler = async ({ locals }) => {
const { pb, user } = locals;
let output;
try {
output = await pb.collection("notifications")?.getFullList({
filter: `opUser="${user?.id}" `,
expand: "user,post,comment",
sort: "-created",
});
} catch (e) {
console.log(e);
output = [];
}
return new Response(JSON.stringify(output));
};