预期的承诺或价值

预期的承诺或价值

本文介绍了返回的函数未定义,预期的承诺或价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我在firebase上触发简单的数据库触发器,然后它会显示如下错误:函数返回了不确定的,期望的承诺或价值"

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

const firebase=require('firebase-admin');

const functions = require('firebase-functions');
firebase.initializeApp(functions.config().firebase);

exports.helloNotification = functions.database.ref('/users').onWrite(event => {

 return "A Notification has been deleted from the database ";
});

推荐答案

如果函数中没有异步工作要做,只需return null.返回字符串在Cloud Functions中没有任何意义.如果您出于某些原因需要退还承诺,只需return Promise.resolve().

If you don't have any asynchronous work to do in a function, just return null. Returning a string doesn't have any meaning in Cloud Functions. If you need to return a promise for some reason, just return Promise.resolve().

这篇关于返回的函数未定义,预期的承诺或价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 11:59