开发者社区> 问答> 正文

云功能部署

我一直在尝试将云功能部署到我的Firebase项目中。这是我第一次这样做,也是我第一次使用JavaScript编程。


Node.js

'use strict'
const admin = require('firebase-admin');
const functions = require('firebase-functions');
admin.initializeApp(functions.config().firebase);

const firebaseTriggers = functions.region('europe-west1').firestore;
const db = admin.firestore();

exports.postNotification = firebaseTriggers
      .document('/post notifications/{notificatioId}').onWrite((snap, context) => {
      const notifcationRecieverId = snap.data().mReciever;
      const payload = {
        data: {
            notification_type: 'POST',
            title: snap.data().mTitle,
            body: snap.data().mDescription,
            sender_id: snap.data().mSender,
            reciever_id: snap.data().mReciever,
            notification_id: context.params.notificatioId
        }
      };
      return db.collection('dog owners')
        .document(notifcationRecieverId)
        .get()
        .then(recieverDoc => {
            console.log('Retrieving FCM tokens');
            const tokens = recieverDoc.data().mTokens;
            console.log('Sending notification payload');
            return admin.message().sendToDevice(tokens, payload);
        });
});

我在cmd的部署屏幕截图中遇到此错误

展开
收起
Puppet 2020-01-12 09:14:38 632 0
1 条回答
写回答
取消 提交回答
  • 首先,您的大学名称中有空格。对流不好。

    post notifications => postNotifications

    2020-01-12 09:14:51
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
云上之旅-阿里云云上指引框架 立即下载
云上之旅—阿里云云上指引框架 立即下载
无影云电脑,构建云上安全办公解决方案 立即下载