- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
'use strict'
//Install functions and admin sdks'
const functions = require('firebase-functions');
const admin =require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.sendNotification = functions.database.ref('/notifications/{user_id}/{notification_id}').onWrite((change, context) => {
//onwrite will run if data changed
const user_id = context.params.user_id;
const notification = context.params.notification;
if (context.params === null) {
return console.log("Notification Has Been Deleted");
}
let token_id = null;
const deviceToken = admin.database.ref(`/Users/${user_id}/device_token`).once('value');
return deviceToken.then(result => {
token_id = result.val();
const payload = {
notification:{
title:"Friend Request",
body:"You have recieved a new friend request",
icon:"default"
}
};
});
return admin.messaging().sendToDevice(token_id, payload).then(response =>{
console.log('This is the notify feature');
}).catch(err => {
console.log('Error getting documents', err);
});
});
运行 firebase deploy 命令时出现如下错误。如果有人可以支持,我将不胜感激。
error 每个 then() 应该返回一个值或抛出 promise/always-returnerror 无法访问的代码 no-unreachableerror 每个 then() 应该返回一个值或抛出 promise/always-return
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions@ lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
最佳答案
希望一切顺利,你应该这样回来
return console.log('This is the notify feature');
关于node.js - Firebase 云函数说 Unreachable 并且每个 then() 应该返回一个值或抛出 promise/always-return,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49841484/
我正在学习 React.js。我大约 2 天前搜索了我的问题的解决方案,但我不知道问题是什么。 render() { return ( { this.state.menus.
我是在 React 中创建 GET 请求的新手。当有人在输入字段中输入 url 时,我试图从 Instagram 内容中获取 media_id。有趣的是,我确实在 Inspector 中收到了以下 G
我在 C 应用程序的套接字之间发送数据。我首先绑定(bind)“接收器”以监听 127.0.0.1 (localhost) 的某个端口(阻塞 - 在单独的线程中)。然后我开始向这个端口发送数据。 我从
我有两个关于常见的目标无法到达异常的问题。处理它的最佳做法是什么,例如您有:国家有城市,城市有街道。- 你是否放入 Country 的构造函数 new City() 和 City 的构造函数 new
我在带有 innodb 引擎的 mysql 数据库中有一个非常大的表。 现在我想使用以下脚本引入一个新索引: 几分钟后它告诉我: ERROR: Error when running failback
我有一个简单的小装饰器,它将函数调用的结果作为函数属性缓存在 dict 中。 from decorator import decorator def _dynamic_programming(f, *
我收到代码的错误“RuntimeError: unreachable in rustwasm” 错误信息: Uncaught (in promise) RuntimeError: unreachabl
已移动:https://superuser.com/questions/782549/udp-client-sending-icmp-port-unreachable-when-receiveing-
我反编译了一个APK文件,然后尝试编译它并收到“无法访问的语句”编译器错误,我想知道这是混淆器技巧还是反编译器失败?这怎么可能?用过的 dex2jar和 Java Decompiler 这是反编译的方
灵感来自这个问题的答案 Is empty case of switch in C# combined with the next non-empty one? 此术语唯一出现在 C# 语言规范的 §6
这个问题在这里已经有了答案: Why does Java have an "unreachable statement" compiler error? (8 个答案) 关闭 7 年前。 您好,我尝
我正在研究 Java PDF 库。 我已经尝试过了 org.apache.pdfbox File file = new File("file.pdf"); PDDocument document =
大家晚上好, 我在介绍性 java 类的一些代码中遇到了编译问题。手头的应用程序创建了一个计算器。当尝试编译时,我收到一条错误,指出我有一个“无法访问的语句”,这让我相信我陷入了某个循环(同样,我正在
为什么我会收到第 92 行是无法访问的语句的错误?基本上我想做的是跳过一些代码,如 21-22-23... 如果用户输入类似 11-12-13... import java.util.*; publi
我的程序中有些东西没有意义。可能是我的 while 语句在它的循环中嵌入了几个不同的 if 语句。但主要错误是指向我的 while 循环之后,我似乎无法弄清楚。我评论了错误的地方。 这是程序的样子:
这个问题在这里已经有了答案: Unreachable code compiler error [duplicate] (7 个答案) 关闭 7 年前。 为什么这个方法会返回错误:Error: Unr
我目前正在使用 Eclipse 编写一个新插件。我一直在网上关注教程,但是遇到了错误。我的 friend 一直在帮助编写代码,但他不确定此修复程序。我遇到了“无法访问的代码”错误。我已经标记了错误的位
Eclipse 强制我对任何 switch 使用 default 案例,包括那些列出所有声明的 enum 值的案例,据称是因为语言规范 [ 1 ].这是不幸的,因为并行开发项目的 Android St
这是我的 Android代码。我在下面的行 Toast 中有错误上面写着“Unreachable Statement”,我知道这个错误来自 return我的If但是不知道怎么解决 错误部分: do {
我有两台机器正在测试我的代码,一台工作正常,另一台我遇到了一些问题,我不知道为什么会这样。 我正在为项目的网络部分使用一个对象 (C++)。在服务器端,我这样做:(为清楚起见删除了错误检查)
我是一名优秀的程序员,十分优秀!