我正在尝试编写一个函数,该函数在用户获得新评论并发送通知时触发。评论存储在/ Users / {user_id} / Notifications / {notification_id}中。用户将其设备通知令牌保存到/ users / {userID}
class FlaskTestCase(unittest.TestCase):
highscore = {1:2}
def test_initial_word(self):
with app.app_context():
response = self.app.get("/final", data = dict(self.highscore , user = "test", score = 12))
self.assertIn("quick and easy game", str(response.data))
这是package.json文件。一切都是最新的
def test_initial_word(self):#Check if game.html has been created
with app.app_context():
response = self.app.get("/rules", data = dict(user = "test", score = 12))
self.assertIn("test", str(response.data))
Firebase出现以下错误:
'use strict'
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.sendNotif = functions.firestore.document('Users/{user_id}/Notifications/{notification_id}')
.onWrite((change,context) =>
{
const user_id = context.params.user_id;
const notification_id = context.params.notification_id;
return admin.firestore().collection('Users').document(user_id).collection('Notifications').document(notification_id).get().then(queryResult=>{
const from_user_id = queryResult.data().From;
const from_data = admin.firestore().collection('Users').document(from_user_id).get();
const to_data = admin.firestore().collection('Users').document(user_id).get();
return Promise.all([from_data, to_data]).then(result => {
const from_name = result[0].data().From;
const to_name = result[1].data().From;
console.log("FROM: " + from_name + "TO: " + to_name);
});
});
});
答案 0 :(得分:0)
请检查阵列的长度(结果)。您应该记录结果。
return Promise.all([from_data, to_data]).then(result => {
console.log(result);
const from_name = result[0].data().From;
const to_name = result[1].data().From;
console.log("FROM: " + from_name + "TO: " + to_name);
});