【问题标题】:error Error: could not handle the requesterror 错误:无法处理请求
【发布时间】:2018-05-05 12:16:23
【问题描述】:

import * as functions from 'firebase-functions'
import * as admin from 'firebase-admin'

admin.initializeApp()

export const helloWorld = functions.https.onRequest((request, response) => {
    response.send("")
})

export const clientRequest = functions.https.onRequest((request, response) => {

    //if (["POST", "OPTIONS"].indexOf(request.method.toUpperCase()) === -1) response.send('wrong request type')

    const store = admin.firestore()

    const sendData = {
        clientName: 'qwe!'
    };

    store
        .collection('items')
        .add(sendData)
        .then(success => {
            response.send("");
        }).catch(error => {
            response.send(error)
        })
})

为什么?昨天的工作!

i 函数:用于上传的打包函数 (46.51 KB)
+ 函数:函数文件夹上传成功
i 函数:更新函数 helloWorld...
i 函数:更新函数 clientRequest...
+ functions[clientRequest]: 更新操作成功。
+ functions[helloWorld]:更新操作成功。
+ 部署完成!

【问题讨论】:

  • 如果您尝试重新部署会发生什么?
  • Firebase 控制台上的函数日志中有什么特别之处吗?
  • 函数执行耗时 60002 毫秒,完成状态为:'timeout' 和.. 仅命名函数和三角形红色警告

标签: firebase google-cloud-functions


【解决方案1】:

如果你把代码的结尾改为

    .then(success => {
        response.status(200).send("");
    }).catch(error => {
        response.status(500).send(error)
    })

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-16
  • 2014-07-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多