How do I do a GET for Firebase.functions().httpsCallable?

喜夏-厌秋 提交于 2021-01-28 12:50:38

问题


How do I do a GET for Firebase.functions().httpsCallable? I keep receiving a POST error 404 but this is a GET request to my server. Should I pass in nothing or there is something to change this httpsCallable to get function?

Client

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

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

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

      })

Server

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);

回答1:


If you are just trying to ping your callable function endpoint, a GET won't work. As you can see from the protocol specification for callable functions, it uses a POST. If you use a GET, it's an error because you're not following the protocol.



来源:https://stackoverflow.com/questions/57266680/how-do-i-do-a-get-for-firebase-functions-httpscallable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!