Skip to content

fix: replace readItem with readItems to match usage #349

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

erwan-legoff
Copy link

The code was importing readItem from @directus/sdk but calling readItems, which caused a not found error. Replaced the import with readItems to ensure the method used is actually imported.
It fixes my error when coding.

The code was importing `readItem` from @directus/sdk but calling `readItems`, which caused a not found error.
Replaced the import with `readItems` to ensure the method used is actually imported.
@erwan-legoff erwan-legoff requested a review from a team as a code owner May 16, 2025 13:10
Copy link

vercel bot commented May 16, 2025

@erwan-legoff is attempting to deploy a commit to the Directus Team on Vercel.

A member of the Team first needs to authorize it.

@erwan-legoff
Copy link
Author

After another try, this doesn't seem to work fine neither, always returning the first parge. But this worls :
`import directus from '@/lib/directus';
import { notFound } from 'next/navigation';
import { readItems } from '@directus/sdk';

async function getPage(slug) {
try {
const pages = await directus.request(readItems('pages', {
filter: { slug: { _eq: slug } },
}));
return pages[0];
} catch (error) {
notFound();
}
}

export default async function DynamicPage({ params }) {
const page = await getPage(params.slug);
return (


{page.title}


<div dangerouslySetInnerHTML={{ __html: page.content }}>


);
}`

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

Successfully merging this pull request may close these issues.

1 participant