admin管理员组文章数量:1332896
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);
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);
Share
Improve this question
edited Jul 30, 2019 at 9:56
phongyewtong
asked Jul 30, 2019 at 7:44
phongyewtongphongyewtong
5,31915 gold badges59 silver badges87 bronze badges
2
- 1 What exactly are you expecting this to invoke on the backend? This will only work with a named callbable function on the backend, not some arbitrary HTTP endpoint. firebase.google./docs/functions/callable – Doug Stevenson Commented Jul 30, 2019 at 8:07
- i am trying to do a get request from my server. I testing just using the link on google it works – phongyewtong Commented Jul 30, 2019 at 9:57
1 Answer
Reset to default 5If 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.
本文标签: javascriptHow do I do a GET for Firebasefunctions()httpsCallableStack Overflow
版权声明:本文标题:javascript - How do I do a GET for Firebase.functions().httpsCallable? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742278950a2445733.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论