TanStackT
TanStack4mo ago
5 replies
efficient-indigo

[RC] createServerFn: Getting encoded response in network tab

Hi all,

Since the RC update we are getting encoded responses in the network tab.

export const useGetProduct = createServerFn({ method: 'GET' })
    .inputValidator((input: {
        languageCode: string,
        id?: string,
        slug?: string
    }) => {
        if (!validateLanguageCode(input.languageCode)) {
            throw new Error('Invalid language code')
        }
        if (!input.id && !input.slug) {
            throw new Error('Either id or slug must be provided')
        }
        return input
    })
    .handler(async ({ data }) => {
        const { languageCode, id, slug } = data

        const productData = await serverRequest<GetProductQuery>(getProductQuery, {
            id,
            slug
        }, languageCode)

        if (!productData) {
            throw new Error('Product not found')
        }

        return productData.product
    })


How can we get the raw response back in the network tab?

Example of the encoded response we get now:

{
    "t": 10,
    "i": 0,
    "p": {
        "k": [
            "result",
            "error",
            "context"
        ],
        "v": [
            {
                "t": 10,
                "i": 1,
                "p": {
                    "k": [
                        "activeCustomer"
                    ],
                    "v": [
                        {
                            "t": 2,
                            "s": 0
                        }
                    ],
                    "s": 1
                },
                "o": 0
            },
            {
                "t": 2,
                "s": 1
            },
            {
                "t": 10,
                "i": 2,
                "p": {
                    "k": [],
                    "v": [],
                    "s": 0
                },
                "o": 0
            }
        ],
        "s": 3
    },
    "o": 0
}


Thanks alot!
Was this page helpful?