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
- Attribute Limit Exceeded
Help! I filled in 10 columns in one of my tables and I'm getting this irritating "Attribute Limit Exceeded" error! I even paid to try to make it go away hahaha...
- Issue with Authentication
I am stuck with authentication using appwrite. I am getting bad request 400 error when trying to register though we already have project, database, collection c...
- getaddrinfo EAI_AGAIN when using axios
I have this code to make a get request to an API ```javascript function fetchUserListPerPage(page) { return new Promise(async (resolve, reject) => { ...