如何对 Firebase.functions().httpsCallable 执行 GET?

pho*_*ong 4 javascript firebase google-cloud-functions

如何对 Firebase.functions().httpsCallable 执行 GET?我不断收到 POST 错误 404,但这是对我的服务器的 GET 请求。我应该不传递任何内容,还是需要更改此 httpsCallable 来获取函数?

客户

let updateWorkshop = Firebase.functions().httpsCallable('api/update/workshop');

    updateWorkshop({/* nothing */})
      .then(res => {
        console.log(res);

      }, err => {
        console.log(err);

      })
Run Code Online (Sandbox Code Playgroud)

服务器

app.get('/v3/update/workshop', asyncMiddleware( async (req, res, next) => {
    let results = await UPDATE_WORKSHOP_DATE.Run()
    res.status(200).json({results: results})
}))

exports.api = FUNCTIONS.https.onRequest(app);
Run Code Online (Sandbox Code Playgroud)

Dou*_*son 5

如果您只是尝试 ping 可调用函数端点,则 GET 将不起作用。正如您从可调用函数的协议规范中看到的,它使用 POST。如果您使用 GET,则会出现错误,因为您没有遵循协议。