更新时控制台日志错误,Firebase 控制台
Console Log Error onUpdate, Firebase Console
我在我的 firebase 控制台中部署了 Typescript 中的这个函数:
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;
}
})
部署是正确的,但是当我更改数据时,控制台日志中出现错误:
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)
任何我做错的建议。
仔细阅读错误信息:
Error: Topic provided to sendToTopic() must be a string which matches the format "/topics/[a-zA-Z0-9-_.~%]+".
您提供的字符串 "Settings/ShiftsEditMode" 与要求的模式不匹配。该模式表示字符串应以“/topics/”开头。字符串的其余部分,即您的主题名称,只能包含字母、数字、下划线、点、波形符和百分比。您提供的字符串也不匹配该模式,因为它包含非法斜杠。
我在我的 firebase 控制台中部署了 Typescript 中的这个函数:
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;
}
})
部署是正确的,但是当我更改数据时,控制台日志中出现错误:
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)
任何我做错的建议。
仔细阅读错误信息:
Error: Topic provided to sendToTopic() must be a string which matches the format "/topics/[a-zA-Z0-9-_.~%]+".
您提供的字符串 "Settings/ShiftsEditMode" 与要求的模式不匹配。该模式表示字符串应以“/topics/”开头。字符串的其余部分,即您的主题名称,只能包含字母、数字、下划线、点、波形符和百分比。您提供的字符串也不匹配该模式,因为它包含非法斜杠。