Я пытаюсь развернуть Firebase, но получаю эту ошибку
error Каждое then () должно возвращать значение или выдавать обещание / всегда возвращать
это мой код
'use strict'
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(event => {
const user_id = event.params.user_id;
const notification_id = event.params.notification_id;
console.log('We have a notification from : ', user_id);
if(!event.data.val()){
return console.log('A Notification has been deleted from the database : ', notification_id);
}
const fromUser = admin.database().ref(`/notifications/${user_id}/${notification_id}`).once('value');
return fromUser.then(fromUserResult => {
const from_user_id = fromUserResult.val().from;
console.log('You have new notification from : ', from_user_id);
const userQuery = admin.database().ref(`Users/${from_user_id}/name`).once('value');
const deviceToken = admin.database().ref(`/Users/${user_id}/device_token`).once('value');
return Promise.all([userQuery, deviceToken]).then(result => {
const userName = result[0].val();
const token_id = result[1].val();
const payload = {
notification: {
title : "New Friend Request",
body: `${userName} has sent you request`,
icon: "default",
click_action : "in.tvac.akshaye.lapitchat_TARGET_NOTIFICATION"
},
data : {
from_user_id : from_user_id
}
};
return admin.messaging().sendToDevice(token_id, payload).then(response => {
console.log('This was the notification Feature');
});
});
});
});
это журнал ошибок
нпм ERR! код ELIFECYCLE
нпм ERR! Errno 1
нпм ERR! functions @ lint: eslint .
нпм ERR! Статус выхода 1
нпм ERR!
нпм ERR! Сбой в скрипте functions @ lint.
нпм ERR! Это, вероятно, не проблема с npm. Вероятно, есть дополнительные выходные данные регистрации
нпм ERR! Полный журнал этого прогона можно найти в:
нпм ERR! C: \ Users \ PC \ AppData \ Roaming \ NPM-cache_logs \ 2018-11-09T12_26_46_311Z-debug.log
Ошибка: ошибка предустановки функций: команда завершена с ненулевым кодом выхода1