#Passing req object to Local API

5 messages · Page 1 of 1 (latest)

wanton pasture
#
const existing = await req.payload.find({
            collection: 'users',
            where: { email: { equals: email } },
            limit: 1,
            overrideAccess: true,
            req,
        });

In this code, is it still required to send the req object in the options?
Is it already prefilled because I'm typing req.payload.find?

tender osprey
#

Gonna put this here, but waiting for confirmation from another dev

TLDR: 1) Depends. Technically optional, but usually preferred. 2) No.

In general, you want to pass req in any payload operation calls when you need them to share the same transaction and context (which is usually the case). However, this is not a default behaviour which is why you'll need to explicitly pass req. Calling req.payload does not mean that req is set automatically.

@wanton pasture

prime gardenBOT
#

You do not have permission to mark this thread as solved. Only thread creators, contributors and payload team members can mark a thread as solved.

wanton pasture
#

Great thanks!