next-crud icon indicating copy to clipboard operation
next-crud copied to clipboard

onSuccess callback not working after deployment.

Open kalib-code opened this issue 2 years ago • 0 comments

Hi, I got a problem with the onSuccess callback. if I am on local the callback triggers and I can see the response but after I deploy it on AWS amplify its no longer working. I wanted to send an email invite every time a new user is being added turns out that on my local it's working but after being deployed it's not working anymore.

` onSuccess : async ( req, res, options ) => {

        if (req.method === 'POST') {
            const { email, role, companies : { connect : { id : cid } } } = req.body

            if (role !== 'USER') return

            // get user details from db
            const user = await prisma.user.findUnique ( {
                where : {
                    email : email
                },
            } ) as Prisma.UserCreateInput

            if (req.query.nextcrud.includes ( 'users' )) {

                console.log("[email] sending email to ", email)
                const emailData = {
                    Recipients : {
                        To : [email] // maximum 50 recipients
                    },
                    Content : {
                        Body : [
                            {
                                ContentType : "HTML",
                                Charset : "utf-8",
                                Content : `message `
                            },
                            {
                                ContentType : "PlainText",
                                Charset : "utf-8",
                                Content : `message`
                            }
                        ],
                        From : "[email protected]",
                        Subject : "Video Thread Invitation"
                    }
                }


                try{
                    // @ts-ignore
                    const { data } = await sendTransactionalEmails ( emailData as EmailTransactionalMessageData )
                    console.log("[EMAIL]-[SUCCESS] ", data)
                }catch (e) {
                    console.log("[email] error sending email", e)
                }




            }
        }

    }`

kalib-code avatar Dec 19 '22 02:12 kalib-code