-
Notifications
You must be signed in to change notification settings - Fork 8
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
Sample call to Directus #4
Comments
+1 |
2 similar comments
+1 |
+1 |
To anyone wondering how to make a client-side request. "use client"
import { directus } from "@/services/directus"
import * as React from "react"
import { readItems } from "@directus/sdk"
import { getSession } from "next-auth/react"
export default function Page() {
const [items, setItems] = React.useState([])
React.useEffect(() => {
const fetchItems = async () => {
const session = await getSession()
const api = directus(session?.access_token)
try {
const response = await api.request(readItems("test"))
console.log("Resoinseee", response)
} catch (error) {
console.error("Error fetching items:", error)
}
}
fetchItems()
}, [])
return (
<div>
<h1>Directus Query Example</h1>
<p>Check the console for the logged items.</p>
<p>Number of items fetched: {items.length}</p>
</div>
)
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is not a bug report. This repository is excellent but I am not familiar with Nextjs with SSR.
Would you please provide a sample for a page with a button, which will interact with Directus when clicked?
Thanks for your great code.
The text was updated successfully, but these errors were encountered: