Suiii
TypeScript
Error:
× You're importing a component that needs next/headers. That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/getting-started/
│ react-essentials#server-components
│
│
╭─[P:\web-app\lib\appwrite.ts:1:1]
2 │ import { cookies } from 'next/headers';
TypeScript
useEffect(() => {
const fetchData = async () => {
try {
const model = await loadEmployees()
setEmployees(model.documents as Employee[])
}
} catch (error) {
log.error("Error fetching data SERVER ACTION:", error);
}
}
fetchData();
}, [])
I read the documentation of nextjs , it should be working fine!
TL;DR
Issue with importing a component requiring 'next/headers' in a Server Component not supported in pages/ directory. Make sure to add 'use server' at the top of appwrite.ts file. Kenny
did you put 'use server' at the top of your appwrite.ts file?
Suiii
no. if i put , it getting this error
Recommended threads
- Update User Error
```ts const { users, databases } = await createAdminClient(); const session = await getLoggedInUser(); const user = await users.get(session.$id); if (!use...
- apple exchange code to token
hello guys, im new here 🙂 I have created a project and enabled apple oauth, filled all data (client id, key id, p8 file itself etc). I generate oauth code form...
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...