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.