Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prisma is not defined in server API #41

Open
Corentin7301 opened this issue Sep 23, 2024 · 0 comments
Open

Prisma is not defined in server API #41

Corentin7301 opened this issue Sep 23, 2024 · 0 comments

Comments

@Corentin7301
Copy link

In the doc, I read: You can use the auto-imported Prisma Client instance.

But when I create a API route and I use in my app, I've this error message: prisma is not defined...

I don't understand... And so, what can I import for use prisma in my API route?

// /api/customer.ts

export default defineEventHandler(async (event) => {
    return {
      user: await prisma.user.findFirst(),
    };
  });
<!--app.vue-->

<template>
<div>
  <pre>{{ data }}</pre>
</div>
</template>

<script setup>
const { data } = await useFetch('/api/customer')
</script>

Thanks for help! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant