首页 > 解决方案 > 如何使用 Angular 和 Firestore 将数组发送到电子邮件

问题描述

我正在尝试使用 sendgrid 从 firestore 数据库发送数组数据。

我试过使用文档没有运气。

export const newOrder = functions.firestore
    .document("checkout/{checkoutId}/products/{productId}")
    .onCreate(async (change, context) => {
        // Read booking document
        const postSnap = await db
            .collection("checkout/{checkoutId}/products")
            .doc(context.params.productId)
            .get();

        const booking = postSnap.data() || {};


        //Email
        const msg = {
            to: "wilmutsami@gmail.com",
            from: "test@example.com",
            templateId: TEMPLATE_ID,
            dynamic_template_data: {
                subject: "Hey there, thank you for your order!",
                name: [booking.name],
                amount: [booking.amount]
            }
        };

        //Send it
        return sgMail.send(msg);
    });

标签: node.jsgoogle-cloud-firestoregoogle-cloud-functionssendgrid

解决方案


推荐阅读