Cloud Functions SyntaxError:无法在模块外使用导入语句

时间:2021-02-20 13:42:53

标签: firebase flutter google-cloud-functions firebase-cloud-messaging

我将 TS 用于 Firebase Cloud Functions 并在我想部署该函数时收到此 SyntaxError。

这是我的源代码:

import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';


admin.initializeApp();

const db = admin.firestore();
const fcm = admin.messaging();

export const sendToTopicNewsAusschuss = functions.firestore
.document('news/{newsId}')
.onCreate(async snapshot => {
    const oneNews = snapshot.data();

    const payload: admin.messaging.MessagingPayload = {
        notification: {
            title: 'News',
            body: `${oneNews.newsTitle}`,
            clickAction: 'FLUTTER_NOTIFICATION_CLICK'
        }
    };
    return fcm.sendToTopic('newsausschuss', payload);
    
});

希望你能帮到我

谢谢

0 个答案:

没有答案