根据Firebase文档,云函数需要以res.send()
、res.end()
或res.redirect()
结束。当我使用res.sendFile()
发送文件内容时,控制台日志显示的调用超过1次(实际上是4-5次创新)。
那么,在Firebase函数中使用res.sendFile()
的正确方法是什么呢?
发布于 2017-11-07 11:20:01
可能值得将HTTP代码与sendFile()
链接起来,以推断该函数已成功完成,因此停止再次调用它:
res.status(200).sendFile(...)
关于终止HTTP函数的文档提供了一个只有send()
的示例
formattedDate =矩().format(格式);console.log(发送格式化日期: formattedDate);res.status(200).send(formattedDate);
此外,send()
或Firebase示例库的云功能中的json()
等其他示例都使用status()
。
https://stackoverflow.com/questions/47156359
复制相似问题