#How to access payload in `trpc`

7 messages · Page 1 of 1 (latest)

karmic linden
#
import { publicProcedure } from "../trpc"
import payload from 'payload'

export const getHomepage = publicProcedure.query(async () => {
    await payload.find({
        collection: 'homepage',
    }).then((res) => console.log(res)).catch((err) => console.log(err))
    return {
        hello: "world"
    }
})
APIError {
    data: null,
    isOperational: true,
    isPublic: false,
    status: 500,
    name: 'APIError',
    //...
export default buildConfig({
  admin: {
    user: Users.slug,
  },
  collections: [Users],
  globals: [Homepage],
  //...
export const Homepage: GlobalConfig = {
    slug: 'homepage',
    fields: [
        {
            name: 'title',
            label: 'Title',
            type: 'text',
        },
        {
            name: 'content',
            label: 'Content',
            type: 'richText',
        },
    ],
}
karmic linden
#

Forgot to mention, error says that it can't find collection homepage

topaz plover
#

Is homepage added to the payload config?

#

seems odd that it couldnt find a collection

karmic linden
#

yeah, it was, sorry for late reply

#

I posted it as a code