小编Abh*_*hek的帖子

Firebase:函数返回undefined,预期Promise或value

我正在编写Firebase函数,我在跟踪Firebase提供的Github中的示例代码中的代码 但是,我一直Function returned undefined, expected Promise or value在Firebase函数日志中收到错误 .

我几乎修改了我的代码,但却没有任何喘息的机会.有人试过这段代码吗?它没有错误吗?为什么我收到错误?Firebase指南中也包含相同的代码

产生错误的示例代码如下

  exports.imageToJPG = functions.storage.object().onChange(event => {
  const object = event.data;
  const filePath = object.name;
  const baseFileName = path.basename(filePath, path.extname(filePath));
  const fileDir = path.dirname(filePath);
  const JPEGFilePath = path.normalize(path.format({dir: fileDir, name: baseFileName, ext: JPEG_EXTENSION}));
  const tempLocalFile = path.join(os.tmpdir(), filePath);
  const tempLocalDir = path.dirname(tempLocalFile);
  const tempLocalJPEGFile = path.join(os.tmpdir(), JPEGFilePath);

  // Exit if this is triggered on a file that is not an image.
  if (!object.contentType.startsWith('image/')) {
    console.log('This …
Run Code Online (Sandbox Code Playgroud)

javascript firebase google-cloud-functions

2
推荐指数
1
解决办法
3821
查看次数