I want to organize sending push- notifications on adding a document to firestore. I am using the code from examples from firebase site for node.js.
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
var message = {
notification: {
title: 'title!',
body: 'body'
},
topic: "all"
};
exports.createRequest = functions.firestore
.document('Requests/{RequestsId}')
.onCreate((snap, context) => {
console.log('We have a new request');
// Send a message to devices subscribed to the provided topic.
admin.messaging().send(message)
.then((response) => {
console.log('Successfully sent message:', response);
}).catch((error) => {
console.log('Error sending message:', error);
});
return 0;
});
When I try to deploy I am getting an error:
Each then() should return a value or throw promise/always-return" for string
.then((response) => {