如何为Firebase.functions().httpsCallable进行GET? [英] How do I do a GET for Firebase.functions().httpsCallable?
问题描述
如何为Firebase.functions().httpsCallable进行GET?我一直收到POST错误404,但这是对服务器的GET请求.我应该不输入任何内容,还是可以更改此httpsCallable以获得功能?
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?
客户
let updateWorkshop = Firebase.functions().httpsCallable('api/update/workshop');
updateWorkshop({/* nothing */})
.then(res => {
console.log(res);
}, err => {
console.log(err);
})
服务器
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);
推荐答案
如果您只是想ping通您的可调用函数端点,则GET无法正常工作.从可调用函数的协议规范中可以看到,它使用了POST.如果您使用GET,则会出现错误,因为您未遵循协议.
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.
这篇关于如何为Firebase.functions().httpsCallable进行GET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!