首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >控制台日志错误onUpdate,Firebase控制台

控制台日志错误onUpdate,Firebase控制台
EN

Stack Overflow用户
提问于 2019-03-14 22:19:02
回答 1查看 122关注 0票数 0

在我的firebase控制台中部署的类型记录中有这样的功能:

代码语言:javascript
复制
import * as functions from 'firebase-functions'
import * as admin from 'firebase-admin'

admin.initializeApp()


export const onEditModeUpdate = 
functions.firestore.document("Settings/ShiftsEditMode").onUpdate(change => { 
    if (change.after) {
        const after = change.after.data();
        const payload = {
            data: {
                temp: String(after.temp),
                conditions: String(after.conditions)
        }
    }
    return admin.messaging().sendToTopic("Settings/ShiftsEditMode", payload)
}
else {
    return null;
}
})

部署是正确的,但是当我更改数据时,控制台日志中会出现一个错误:

代码语言:javascript
复制
Error: Topic provided to sendToTopic() must be a string which matches the format "/topics/[a-zA-Z0-9-_.~%]+".
at FirebaseMessagingError.Error (native)
at FirebaseMessagingError.FirebaseError [as constructor] (/user_code/node_modules/firebase-admin/lib/utils/error.js:42:28)
at FirebaseMessagingError.PrefixedFirebaseError [as constructor] (/user_code/node_modules/firebase-admin/lib/utils/error.js:88:28)
at new FirebaseMessagingError (/user_code/node_modules/firebase-admin/lib/utils/error.js:253:16)
at Messaging.validateTopic (/user_code/node_modules/firebase-admin/lib/messaging/messaging.js:964:19)
at /user_code/node_modules/firebase-admin/lib/messaging/messaging.js:650:19
at process._tickDomainCallback (internal/process/next_tick.js:135:7)

请告诉我我做错了什么。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-14 22:23:54

仔细阅读错误消息:

错误:提供给sendToTopic()的主题必须是一个字符串,该字符串必须与格式“/topics/a-Za-Z0-9-_.%+”相匹配。

您提供的字符串"Settings/ShiftsEditMode“与所需的模式不匹配。这个模式是说字符串应该以“/ The /”开头。字符串的其余部分,即主题的名称,只能包含字母、数字、下划线、点、倾斜和百分比。您提供的字符串也与该模式不匹配,因为它包含一个非法斜杠。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55172857

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档