conflicts resolved
This commit is contained in:
27
server/api/articles/[id].get.ts
Normal file
27
server/api/articles/[id].get.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import prisma from '~/lib/prisma';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const id = event.context.params?.id;
|
||||
console.log('prisma' + event.context.params?.id)
|
||||
try {
|
||||
const article = await prisma.article.findUnique({ where: { id } });
|
||||
|
||||
if (!article) {
|
||||
return {
|
||||
success: false,
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: article,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error fetching article:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error.message,
|
||||
};
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user