#NEXTJS ECOMMERCE CMS DASHBOARD WITH SUPABASE

1 messages · Page 1 of 1 (latest)

gentle vapor
#

Hi good day, please I would need help on debugging a db response error I get when trying to use an rpc donation I created in my SUPABASE project that I would use to get the name of any enum_type I create.

So, I created an enum_type called categories and this will be an enum list of values for a column in the products table called category.

I want to fetch the values I have stored in the enum_type in the client side(CMS DASHBOARD THAT CAN BE USED TO ADD PRODUCTS) and use them in a drop-down. Upon writing my route.ts:

import { NextResponse, NextRequest } from "next/server";
import { supabase } from "@/utils/supabase";

export async function GET() {
    try {
        const { data, error } = await supabase.rpc('get_enum_values', {
            enum_type: 'categories'
        });

        if (error) throw error;

        // Handle array return type
        const categories = Array.isArray(data) ? data : [];

        return NextResponse.json({
            success: true,
            categories
        });
    } catch (error: any) {
        console.error("Error fetching categories:", error.message);
        return NextResponse.json({
            success: false,
            error: error.message
        }, { status: 500 });
    }
}

I get this response:
{
"success": "false",
"error": "Could not find the function public.get_enum_values(enum_type) in the schema cache"
}

burnt crownBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)