getFullOrganization function is throwing UNAUTHORIZED

Hey im using the function getFullOrganization to get the organization based on the slug and its throwing UNAUTHORIZED
import { authClient } from '@/lib/auth-client'
import React from 'react'

export default async function OrganizationPage({
params,
}: {
params: Promise<{ organizationSlug: string }>
}) {
const { organizationSlug } = await params

const organization = await authClient.organization.getFullOrganization({
query: { organizationSlug: organizationSlug }
})
return (
<div>
<pre>{JSON.stringify(organization, null, 2)}</pre>
</div>
)
}
import { authClient } from '@/lib/auth-client'
import React from 'react'

export default async function OrganizationPage({
params,
}: {
params: Promise<{ organizationSlug: string }>
}) {
const { organizationSlug } = await params

const organization = await authClient.organization.getFullOrganization({
query: { organizationSlug: organizationSlug }
})
return (
<div>
<pre>{JSON.stringify(organization, null, 2)}</pre>
</div>
)
}
{
"data": null,
"error": {
"status": 401,
"statusText": "UNAUTHORIZED"
}
}
{
"data": null,
"error": {
"status": 401,
"statusText": "UNAUTHORIZED"
}
}
Is there something im missing?
2 Replies
Amari
Amari3w ago
I think you need to pass the headers.
Ping
Ping3w ago
Because your component is a RSC, it's being used on the server, change it to use auth.api instead and also pass headers

Did you find this page helpful?