Function returned undefined, expected Promise or value

后端 未结 3 1931
萌比男神i
萌比男神i 2021-01-16 01:20

Whern i fire Simple database trigger on firebase, then it will shows Error like this : \"Function returned undefined, expected Promise or value\"

         


        
3条回答
  •  遥遥无期
    2021-01-16 01:35

    make some changes

    instead of return statement write console.log('...');

    add 'use strict' at the top of the code

    write admin instead of firebase to initialize the app

    the code looks like

    'use strict'
    const firebase=require('firebase-admin');
    
    const functions = require('firebase-functions');
    admin.initializeApp(functions.config().firebase);
    
    exports.helloNotification = functions.database.ref('/users').onWrite(event => {
    
     console.log('A Notification has been deleted from the database');
    });
    

提交回复
热议问题