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.did you put 'use server' at the top of your appwrite.ts file?
no. if i put , it getting this error
Recommended threads
- Substring lookup for array elements
Hello, Is substring look up possible for array of strings? ```js Query.contains('product_names', [chair]), ``` this only works if I have the exact item name. `...
- Hey everyone! I'm trying to self-host th...
Hey everyone! I'm trying to self-host the latest Appwrite version (1.8.1) on Coolify. Which docker-compose.yml file should I use from their repo? Can someone he...
- Weird Query Error
In next js I am getting this error in the image ```js queries: [ Query.equal('title', TitleId), Query.limit(10) ] ``` am I doing something...