Cannot access 'safeActionClient' before initialization. #319
Unanswered
SanfetCoder
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am currently facing the error mentioned above. It seemed to be working just fine initially. But somehow after updating some code (just change the text of
) and save the code, it threw an error 'Cannot access safeActionClient' before initialization. I guess this might be caused by hot reloading feature of Next js. Any solution to this?
Here is how the code I declared the action clients
`
import { getLineUser } from "@/actions/auth.action";
import { createSafeActionClient } from "next-safe-action";
export const safeActionClient = createSafeActionClient({});
export const authSafeActionClient = createSafeActionClient({}).use(
async ({ next }) => {
const lineUser = await getLineUser();
}
);
`
Here is the function that was called
`
export const getClaimedRewardHistoriesByUserId = safeActionClient
.schema(GetClaimedRewardHistoriesByUserIdParamsSchema)
.action(
async ({
parsedInput: { user_id, filter },
}): Promise<ServerActionResponse<ClaimedRewardHistory[]>> => {
try {
const query = supabaseAdminClient
.from(TABLE_NAME)
.select(", rewards(), users(*)")
.eq("user_id", user_id)
.order("created_at", { ascending: false });
);
`
Beta Was this translation helpful? Give feedback.
All reactions